From 87ae723b527bd8958cf45b47b23f42b28cc48b3d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 8 Sep 2016 09:50:49 -0700 Subject: [PATCH 001/175] For JSX text, construct a single literal node `"foo bar"` instead of `"foo" + " " + "bar"`. --- src/compiler/transformers/jsx.ts | 55 +++++++------------ .../reference/tsxReactEmitWhitespace.js | 6 +- .../reference/tsxReactEmitWhitespace.symbols | 2 +- .../reference/tsxReactEmitWhitespace.types | 2 +- .../jsx/tsxReactEmitWhitespace.tsx | 2 +- 5 files changed, 26 insertions(+), 41 deletions(-) diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 9e6aa507cce..354c1bcad7d 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -151,28 +151,29 @@ namespace ts { } } - function visitJsxText(node: JsxText) { - const text = getTextOfNode(node, /*includeTrivia*/ true); - let parts: Expression[]; + function visitJsxText(node: JsxText): StringLiteral | undefined { + const fixed = fixupWhitespaceAndDecodeEntities(getTextOfNode(node, /*includeTrivia*/ true)); + return fixed !== undefined && createLiteral(fixed); + } + + /** + * JSX trims whitespace at the end and beginning of lines, except that the + * start/end of a tag is considered a start/end of a line only if that line is + * on the same line as the closing tag. See examples in + * tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + * See also https://www.w3.org/TR/html4/struct/text.html#h-9.1 and https://www.w3.org/TR/CSS2/text.html#white-space-model + */ + function fixupWhitespaceAndDecodeEntities(text: string): string | undefined { + let acc: string | undefined; let firstNonWhitespace = 0; let lastNonWhitespace = -1; - // JSX trims whitespace at the end and beginning of lines, except that the - // start/end of a tag is considered a start/end of a line only if that line is - // on the same line as the closing tag. See examples in - // tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx for (let i = 0; i < text.length; i++) { const c = text.charCodeAt(i); if (isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - const part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - if (!parts) { - parts = []; - } - - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(createLiteral(decodeEntities(part))); + const part = decodeEntities(text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); + acc = acc === undefined ? part : acc + " " + part; } firstNonWhitespace = -1; @@ -186,28 +187,12 @@ namespace ts { } if (firstNonWhitespace !== -1) { - const part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(createLiteral(decodeEntities(part))); + const lastPart = decodeEntities(text.substr(firstNonWhitespace)); + return acc ? acc + lastPart : lastPart; } - - if (parts) { - return reduceLeft(parts, aggregateJsxTextParts); + else { + return acc; } - - return undefined; - } - - /** - * Aggregates two expressions by interpolating them with a whitespace literal. - */ - function aggregateJsxTextParts(left: Expression, right: Expression) { - return createAdd(createAdd(left, createLiteral(" ")), right); } /** diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index dd69091569f..1588b53d8f4 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -41,7 +41,7 @@ var p = 0;
; -// Emit "foo" + ' ' + "bar" +// Emit "foo bar"
foo @@ -75,5 +75,5 @@ React.createElement("div", null, " 3 "); React.createElement("div", null, "3"); // Emit no args React.createElement("div", null); -// Emit "foo" + ' ' + "bar" -React.createElement("div", null, "foo" + " " + "bar"); +// Emit "foo bar" +React.createElement("div", null, "foo bar"); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index a0d8266faa0..4639e828b52 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -79,7 +79,7 @@ var p = 0;
; >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) -// Emit "foo" + ' ' + "bar" +// Emit "foo bar"
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index 824aa5cfdae..ce6911f9874 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -88,7 +88,7 @@ var p = 0;
; >div : any -// Emit "foo" + ' ' + "bar" +// Emit "foo bar"
>
foo bar
: JSX.Element >div : any diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx index 34fd158eab1..9977803e395 100644 --- a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -42,7 +42,7 @@ var p = 0;
; -// Emit "foo" + ' ' + "bar" +// Emit "foo bar"
foo From 9ae98d6a378805661f802974f3794ce5481f1529 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 8 Sep 2016 12:49:58 -0700 Subject: [PATCH 002/175] Fix bug: return `undefined`, not `false` --- src/compiler/transformers/jsx.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 354c1bcad7d..2a18adeda0e 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -153,7 +153,7 @@ namespace ts { function visitJsxText(node: JsxText): StringLiteral | undefined { const fixed = fixupWhitespaceAndDecodeEntities(getTextOfNode(node, /*includeTrivia*/ true)); - return fixed !== undefined && createLiteral(fixed); + return fixed === undefined ? undefined : createLiteral(fixed); } /** From aa322ea18ae247e63eec6e6ae9d828e61525c1a5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 9 Sep 2016 06:32:45 -0700 Subject: [PATCH 003/175] Add test with backslash --- tests/baselines/reference/tsxReactEmitWhitespace.js | 9 +++++++++ .../baselines/reference/tsxReactEmitWhitespace.symbols | 9 +++++++++ tests/baselines/reference/tsxReactEmitWhitespace.types | 10 ++++++++++ tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx | 7 +++++++ 4 files changed, 35 insertions(+) diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index 1588b53d8f4..f8bdead81d2 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -50,6 +50,13 @@ var p = 0;
; +// Emit "hello\\ world" +
+ + hello\ + +world +
; //// [file.js] @@ -77,3 +84,5 @@ React.createElement("div", null, "3"); React.createElement("div", null); // Emit "foo bar" React.createElement("div", null, "foo bar"); +// Emit "hello\\ world" +React.createElement("div", null, "hello\\ world"); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index 4639e828b52..bb04dbf04b9 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -90,4 +90,13 @@ var p = 0;
; >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) +// Emit "hello\\ world" +
+>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) + + hello\ + +world +
; +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index ce6911f9874..25aed60f647 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -100,4 +100,14 @@ var p = 0; ; >div : any +// Emit "hello\\ world" +
+>
hello\world
: JSX.Element +>div : any + + hello\ + +world +
; +>div : any diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx index 9977803e395..4853a504744 100644 --- a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -51,3 +51,10 @@ var p = 0; ; +// Emit "hello\\ world" +
+ + hello\ + +world +
; From 31669504b9e94e452b053c22d6d37834fd13ed34 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 9 Sep 2016 07:56:01 -0700 Subject: [PATCH 004/175] Comment code and remember to add a space before the last part --- src/compiler/transformers/jsx.ts | 43 ++++++++++++++----- .../reference/tsxReactEmitWhitespace.js | 7 +++ .../reference/tsxReactEmitWhitespace.symbols | 8 ++++ .../reference/tsxReactEmitWhitespace.types | 9 ++++ .../jsx/tsxReactEmitWhitespace.tsx | 5 +++ 5 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 2a18adeda0e..556c26c37f0 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -162,23 +162,39 @@ namespace ts { * on the same line as the closing tag. See examples in * tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx * See also https://www.w3.org/TR/html4/struct/text.html#h-9.1 and https://www.w3.org/TR/CSS2/text.html#white-space-model + * + * An equivalent algorithm would be: + * - If there is only one line, return it. + * - If there is only whitespace (but multiple lines), return `undefined`. + * - Split the text into lines. + * - 'trimRight' the first line, 'trimLeft' the last line, 'trim' middle lines. + * - Decode entities on each line (individually). + * - Remove empty lines and join the rest with " ". */ function fixupWhitespaceAndDecodeEntities(text: string): string | undefined { let acc: string | undefined; + // First non-whitespace character on this line. let firstNonWhitespace = 0; + // Last non-whitespace character on this line. let lastNonWhitespace = -1; + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitsepace, + // but lastNonWhitespace = -1 as a special flag to indicate that we *don't* include the line if it's all whitespace. for (let i = 0; i < text.length; i++) { const c = text.charCodeAt(i); if (isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - const part = decodeEntities(text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); - acc = acc === undefined ? part : acc + " " + part; + // If we've seen any non-whitespace characters on this line, add the 'trim' of the line. + // (lastNonWhitespace === -1 is a special flag to detect whether the first line is all whitespace.) + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } + // Reset firstNonWhitespace for the next line. + // Don't bother to reset lastNonWhitespace because we ignore it if firstNonWhitespace = -1. firstNonWhitespace = -1; } - else if (!isWhiteSpace(c)) { + else if (!isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; @@ -186,13 +202,18 @@ namespace ts { } } - if (firstNonWhitespace !== -1) { - const lastPart = decodeEntities(text.substr(firstNonWhitespace)); - return acc ? acc + lastPart : lastPart; - } - else { - return acc; - } + return firstNonWhitespace !== -1 + // Last line had a non-whitespace character. Emit the 'trimLeft', meaning keep trailing whitespace. + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + // Last line was all whitespace, so ignore it + : acc; + } + + function addLineOfJsxText(acc: string | undefined, trimmedLine: string): string { + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + const decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } /** diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index f8bdead81d2..54839412567 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -57,6 +57,11 @@ var p = 0; world ; + +// Emit " a b c d " +
a + b c + d
; //// [file.js] @@ -86,3 +91,5 @@ React.createElement("div", null); React.createElement("div", null, "foo bar"); // Emit "hello\\ world" React.createElement("div", null, "hello\\ world"); +// Emit " a b c d " +React.createElement("div", null, " a b c d "); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index bb04dbf04b9..baac01227b6 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -100,3 +100,11 @@ world ; >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) +// Emit " a b c d " +
a +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) + + b c + d
; +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index 25aed60f647..46ce9f305b4 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -111,3 +111,12 @@ world ; >div : any +// Emit " a b c d " +
a +>
a b c d
: JSX.Element +>div : any + + b c + d
; +>div : any + diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx index 4853a504744..be677b37ff8 100644 --- a/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx @@ -58,3 +58,8 @@ var p = 0; world ; + +// Emit " a b c d " +
a + b c + d
; From 536d703d9ec3f208809a23b20b6058ebf38eae20 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 12 Oct 2016 18:05:01 -0700 Subject: [PATCH 005/175] Set maxNodeModuleJsDepth for inferred projects --- .../unittests/tsserverProjectSystem.ts | 22 +++++++++++++++++++ src/server/project.ts | 7 ++++++ 2 files changed, 29 insertions(+) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 08e4bac7b2c..3e34b796955 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -2387,4 +2387,26 @@ namespace ts.projectSystem { assert.isTrue(errorResult.length === 0); }); }); + + describe("maxNodeModuleJsDepth for inferred projects", () => { + it("should be set by default", () => { + const file1: FileOrFolder = { + path: "/a/b/file1.js", + content: `var t = require("test"); t.` + }; + const moduleFile: FileOrFolder = { + path: "/a/b/node_modules/test/index.js", + content: `var v = 10; module.exports = v;` + }; + + const host = createServerHost([file1, moduleFile]); + const projectService = createProjectService(host); + projectService.openClientFile(file1.path); + + const project = projectService.inferredProjects[0]; + const sourceFile = project.getSourceFile(file1.path); + assert.isTrue("test" in sourceFile.resolvedModules); + assert.equal((sourceFile.resolvedModules["test"]).resolvedFileName, moduleFile.path); + }); + }); } \ No newline at end of file diff --git a/src/server/project.ts b/src/server/project.ts index a355d75f942..91e898bb568 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -126,6 +126,13 @@ namespace ts.server { this.compilerOptions.allowNonTsExtensions = true; } + if (this.projectKind === ProjectKind.Inferred) { + // Add default compiler options for inferred projects here + if (this.compilerOptions.maxNodeModuleJsDepth === undefined) { + this.compilerOptions.maxNodeModuleJsDepth = 2; + } + } + if (languageServiceEnabled) { this.enableLanguageService(); } From fc5b2e524de5e6118970ab8b0f7eb4e1dfb2445f Mon Sep 17 00:00:00 2001 From: about-code Date: Sun, 16 Oct 2016 18:34:57 +0200 Subject: [PATCH 006/175] Fix for issue #442 --- .../staticPropertyNameConflictsEs5.ts | 26 +++++++++++++++++++ .../staticPropertyNameConflictsEs6.ts | 25 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts new file mode 100644 index 00000000000..0f260673d9d --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts @@ -0,0 +1,26 @@ +// @target: es5 + +// static name +class A { + static name: number; // error + name: string; // ok +} + +class B { + static name() {} // error + name() {} // ok +} + + + +// static length... +class C { + static length: number; // error + length: string; // ok +} + +class D { + static length() {} // error + length() {} // ok +} + diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts new file mode 100644 index 00000000000..47c7dbbde25 --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts @@ -0,0 +1,25 @@ +// @target: es6 + + +// static name +class A { + static name: string; // ok + name: string; // ok +} + +class B { + static name() {}; // ok + name() {}; // ok +} + + +// static length +class C { + static length: number; // ok + length: string; // ok +} + +class D { + static length() {} // ok + length() {} // ok +} From 8a37a162b2d15fd04d3f8961269e66951bda1343 Mon Sep 17 00:00:00 2001 From: about-code Date: Sun, 16 Oct 2016 18:43:55 +0200 Subject: [PATCH 007/175] Fix for issue #442 --- src/compiler/checker.ts | 45 +++++++ src/compiler/diagnosticMessages.json | 5 +- .../propertyNamedPrototype.errors.txt | 10 ++ ...cMemberOfAnotherClassAssignment.errors.txt | 30 ++--- ...AndPublicMemberOfAnotherClassAssignment.js | 26 ++-- .../staticPropertyNameConflictsEs5.errors.txt | 92 ++++++++++++++ .../staticPropertyNameConflictsEs5.js | 120 ++++++++++++++++++ .../staticPropertyNameConflictsEs6.errors.txt | 80 ++++++++++++ .../staticPropertyNameConflictsEs6.js | 89 +++++++++++++ .../staticPrototypeProperty.errors.txt | 8 +- ...AndPublicMemberOfAnotherClassAssignment.ts | 14 +- .../staticPropertyNameConflictsEs5.ts | 42 +++++- .../staticPropertyNameConflictsEs6.ts | 49 +++++-- 13 files changed, 558 insertions(+), 52 deletions(-) create mode 100644 tests/baselines/reference/propertyNamedPrototype.errors.txt create mode 100644 tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt create mode 100644 tests/baselines/reference/staticPropertyNameConflictsEs5.js create mode 100644 tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt create mode 100644 tests/baselines/reference/staticPropertyNameConflictsEs6.js diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8568cd5feed..f4f3a77e9be 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13922,6 +13922,50 @@ namespace ts { } } + // Static members may conflict with non-configurable non-writable built-in Function.prototype properties + // see https://github.com/microsoft/typescript/issues/442. + function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { + const es5_descriptors: PropertyDescriptorMap = { + // see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 + // see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 + "name": {configurable: false, writable: false}, + "length": {configurable: false, writable: false}, + "prototype": {configurable: false, writable: false}, + + // see https://github.com/microsoft/typescript/issues/442 + "caller": {configurable: false, writable: false}, + "arguments": {configurable: false, writable: false} + }; + const post_es5_descriptors: PropertyDescriptorMap = { + // see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor + // see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances + "name": {configurable: true, writable: false}, + "length": {configurable: true, writable: false}, + "prototype": {configurable: false, writable: false}, + "caller": {configurable: false, writable: false}, + "arguments": {configurable: false, writable: false} + }; + const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + const className = getSymbolOfNode(node).name; + + for (let member of node.members) { + let isStatic = forEach(member.modifiers, (m:Modifier) => m.kind === SyntaxKind.StaticKeyword); + if (isStatic) { + let memberNameNode = member.name; + let memberName = getPropertyNameForPropertyNameNode(memberNameNode); + let descriptor: PropertyDescriptor = null; + if (languageVersion <= ScriptTarget.ES5) { + descriptor = es5_descriptors.hasOwnProperty(memberName) ? es5_descriptors[memberName] : null; + } else if (languageVersion > ScriptTarget.ES5) { + descriptor = post_es5_descriptors.hasOwnProperty(memberName) ? post_es5_descriptors[memberName] : null; + } + if (descriptor && descriptor.configurable === false && descriptor.writable === false) { + error(memberNameNode, message, memberName, className); + } + } + } + } + function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) { const names = createMap(); for (const member of node.members) { @@ -16423,6 +16467,7 @@ namespace ts { const staticType = getTypeOfSymbol(symbol); checkTypeParameterListsIdentical(node, symbol); checkClassForDuplicateDeclarations(node); + checkClassForStaticPropertyNameConflicts(node); const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6210a20afa6..6b0a6d6dfb7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1955,6 +1955,10 @@ "category": "Error", "code": 2691 }, + "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'.": { + "category": "Error", + "code": 2692 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2239,7 +2243,6 @@ "category": "Message", "code": 4090 }, - "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 diff --git a/tests/baselines/reference/propertyNamedPrototype.errors.txt b/tests/baselines/reference/propertyNamedPrototype.errors.txt new file mode 100644 index 00000000000..6ddd8390720 --- /dev/null +++ b/tests/baselines/reference/propertyNamedPrototype.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts(3,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts (1 errors) ==== + class C { + prototype: number; // ok + static prototype: C; // error + ~~~~~~~~~ +!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. + } \ No newline at end of file diff --git a/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.errors.txt b/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.errors.txt index 59626540806..36ead708331 100644 --- a/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.errors.txt +++ b/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.errors.txt @@ -1,43 +1,43 @@ tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts(12,1): error TS2322: Type 'C' is not assignable to type 'A'. - Property 'name' is missing in type 'C'. + Property 'prop' is missing in type 'C'. tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts(13,1): error TS2322: Type 'typeof B' is not assignable to type 'A'. - Property 'name' is missing in type 'typeof B'. + Property 'prop' is missing in type 'typeof B'. tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts(16,5): error TS2322: Type 'C' is not assignable to type 'B'. - Property 'name' is missing in type 'C'. + Property 'prop' is missing in type 'C'. tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts(17,1): error TS2322: Type 'typeof B' is not assignable to type 'B'. - Property 'name' is missing in type 'typeof B'. + Property 'prop' is missing in type 'typeof B'. ==== tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts (4 errors) ==== interface A { - name(); + prop(); } class B { - public name() { } + public prop() { } } class C { - public static name() { } + public static prop() { } } var a: A = new B(); - a = new C(); // error name is missing + a = new C(); // error prop is missing ~ !!! error TS2322: Type 'C' is not assignable to type 'A'. -!!! error TS2322: Property 'name' is missing in type 'C'. - a = B; // error name is missing +!!! error TS2322: Property 'prop' is missing in type 'C'. + a = B; // error prop is missing ~ !!! error TS2322: Type 'typeof B' is not assignable to type 'A'. -!!! error TS2322: Property 'name' is missing in type 'typeof B'. +!!! error TS2322: Property 'prop' is missing in type 'typeof B'. a = C; - var b: B = new C(); // error name is missing + var b: B = new C(); // error prop is missing ~ !!! error TS2322: Type 'C' is not assignable to type 'B'. -!!! error TS2322: Property 'name' is missing in type 'C'. - b = B; // error name is missing +!!! error TS2322: Property 'prop' is missing in type 'C'. + b = B; // error prop is missing ~ !!! error TS2322: Type 'typeof B' is not assignable to type 'B'. -!!! error TS2322: Property 'name' is missing in type 'typeof B'. +!!! error TS2322: Property 'prop' is missing in type 'typeof B'. b = C; b = a; diff --git a/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.js b/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.js index 1b98daa226d..00de82a4f6d 100644 --- a/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.js +++ b/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.js @@ -1,21 +1,21 @@ //// [staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts] interface A { - name(); + prop(); } class B { - public name() { } + public prop() { } } class C { - public static name() { } + public static prop() { } } var a: A = new B(); -a = new C(); // error name is missing -a = B; // error name is missing +a = new C(); // error prop is missing +a = B; // error prop is missing a = C; -var b: B = new C(); // error name is missing -b = B; // error name is missing +var b: B = new C(); // error prop is missing +b = B; // error prop is missing b = C; b = a; @@ -29,21 +29,21 @@ c = a; var B = (function () { function B() { } - B.prototype.name = function () { }; + B.prototype.prop = function () { }; return B; }()); var C = (function () { function C() { } - C.name = function () { }; + C.prop = function () { }; return C; }()); var a = new B(); -a = new C(); // error name is missing -a = B; // error name is missing +a = new C(); // error prop is missing +a = B; // error prop is missing a = C; -var b = new C(); // error name is missing -b = B; // error name is missing +var b = new C(); // error prop is missing +b = B; // error prop is missing b = C; b = a; var c = new B(); diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt new file mode 100644 index 00000000000..182b1628522 --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt @@ -0,0 +1,92 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(4,12): error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(9,12): error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(15,12): error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(20,12): error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(26,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2300: Duplicate identifier 'prototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(37,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(42,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(48,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(53,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts (11 errors) ==== + + // static name + class StaticName { + static name: number; // error + ~~~~ +!!! error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. + name: string; // ok + } + + class StaticNameFn { + static name() {} // error + ~~~~ +!!! error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. + name() {} // ok + } + + + class StaticLength { + static length: number; // error + ~~~~~~ +!!! error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. + length: string; // ok + } + + class StaticLengthFn { + static length() {} // error + ~~~~~~ +!!! error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. + length() {} // ok + } + + + class StaticPrototype { + static prototype: number; // error + ~~~~~~~~~ +!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. + prototype: string; // ok + } + + class StaticPrototypeFn { + static prototype() {} // error + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. + prototype() {} // ok + } + + + class StaticCaller { + static caller: number; // error + ~~~~~~ +!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. + caller: string; // ok + } + + class StaticCallerFn { + static caller() {} // error + ~~~~~~ +!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. + caller() {} // ok + } + + + class StaticArguments { + static arguments: number; // error + ~~~~~~~~~ +!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. + arguments: string; // ok + } + + class StaticArgumentsFn { + static arguments() {} // error + ~~~~~~~~~ +!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + arguments() {} // ok + } + \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs5.js b/tests/baselines/reference/staticPropertyNameConflictsEs5.js new file mode 100644 index 00000000000..06d4a011a8e --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflictsEs5.js @@ -0,0 +1,120 @@ +//// [staticPropertyNameConflictsEs5.ts] + +// static name +class StaticName { + static name: number; // error + name: string; // ok +} + +class StaticNameFn { + static name() {} // error + name() {} // ok +} + + +class StaticLength { + static length: number; // error + length: string; // ok +} + +class StaticLengthFn { + static length() {} // error + length() {} // ok +} + + +class StaticPrototype { + static prototype: number; // error + prototype: string; // ok +} + +class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok +} + + +class StaticCaller { + static caller: number; // error + caller: string; // ok +} + +class StaticCallerFn { + static caller() {} // error + caller() {} // ok +} + + +class StaticArguments { + static arguments: number; // error + arguments: string; // ok +} + +class StaticArgumentsFn { + static arguments() {} // error + arguments() {} // ok +} + + +//// [staticPropertyNameConflictsEs5.js] +// static name +var StaticName = (function () { + function StaticName() { + } + return StaticName; +}()); +var StaticNameFn = (function () { + function StaticNameFn() { + } + StaticNameFn.name = function () { }; // error + StaticNameFn.prototype.name = function () { }; // ok + return StaticNameFn; +}()); +var StaticLength = (function () { + function StaticLength() { + } + return StaticLength; +}()); +var StaticLengthFn = (function () { + function StaticLengthFn() { + } + StaticLengthFn.length = function () { }; // error + StaticLengthFn.prototype.length = function () { }; // ok + return StaticLengthFn; +}()); +var StaticPrototype = (function () { + function StaticPrototype() { + } + return StaticPrototype; +}()); +var StaticPrototypeFn = (function () { + function StaticPrototypeFn() { + } + StaticPrototypeFn.prototype = function () { }; // error + StaticPrototypeFn.prototype.prototype = function () { }; // ok + return StaticPrototypeFn; +}()); +var StaticCaller = (function () { + function StaticCaller() { + } + return StaticCaller; +}()); +var StaticCallerFn = (function () { + function StaticCallerFn() { + } + StaticCallerFn.caller = function () { }; // error + StaticCallerFn.prototype.caller = function () { }; // ok + return StaticCallerFn; +}()); +var StaticArguments = (function () { + function StaticArguments() { + } + return StaticArguments; +}()); +var StaticArgumentsFn = (function () { + function StaticArgumentsFn() { + } + StaticArgumentsFn.arguments = function () { }; // error + StaticArgumentsFn.prototype.arguments = function () { }; // ok + return StaticArgumentsFn; +}()); diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt new file mode 100644 index 00000000000..b76b7e02b76 --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt @@ -0,0 +1,80 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2300: Duplicate identifier 'prototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(42,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(53,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (7 errors) ==== + + + class StaticName { + static name: number; // ok + name: string; // ok + } + + class StaticNameFn { + static name() {} // ok + name() {} // ok + } + + + class StaticLength { + static length: number; // ok + length: string; // ok + } + + class StaticLengthFn { + static length() {} // ok + length() {} // ok + } + + + class StaticPrototype { + static prototype: number; // error + ~~~~~~~~~ +!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. + prototype: string; // ok + } + + class StaticPrototypeFn { + static prototype() {} // error + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. + prototype() {} // ok + } + + + class StaticCaller { + static caller: number; // // error + ~~~~~~ +!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. + caller: string; // ok + } + + class StaticCallerFn { + static caller() {} // // error + ~~~~~~ +!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. + caller() {} // ok + } + + + class StaticArguments { + static arguments: number; // // error + ~~~~~~~~~ +!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. + arguments: string; // ok + } + + class StaticArgumentsFn { + static arguments() {} // // error + ~~~~~~~~~ +!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + arguments() {} // ok + } + \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.js b/tests/baselines/reference/staticPropertyNameConflictsEs6.js new file mode 100644 index 00000000000..67756c37a92 --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.js @@ -0,0 +1,89 @@ +//// [staticPropertyNameConflictsEs6.ts] + + +class StaticName { + static name: number; // ok + name: string; // ok +} + +class StaticNameFn { + static name() {} // ok + name() {} // ok +} + + +class StaticLength { + static length: number; // ok + length: string; // ok +} + +class StaticLengthFn { + static length() {} // ok + length() {} // ok +} + + +class StaticPrototype { + static prototype: number; // error + prototype: string; // ok +} + +class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok +} + + +class StaticCaller { + static caller: number; // // error + caller: string; // ok +} + +class StaticCallerFn { + static caller() {} // // error + caller() {} // ok +} + + +class StaticArguments { + static arguments: number; // // error + arguments: string; // ok +} + +class StaticArgumentsFn { + static arguments() {} // // error + arguments() {} // ok +} + + +//// [staticPropertyNameConflictsEs6.js] +class StaticName { +} +class StaticNameFn { + static name() { } // ok + name() { } // ok +} +class StaticLength { +} +class StaticLengthFn { + static length() { } // ok + length() { } // ok +} +class StaticPrototype { +} +class StaticPrototypeFn { + static prototype() { } // error + prototype() { } // ok +} +class StaticCaller { +} +class StaticCallerFn { + static caller() { } // // error + caller() { } // ok +} +class StaticArguments { +} +class StaticArgumentsFn { + static arguments() { } // // error + arguments() { } // ok +} diff --git a/tests/baselines/reference/staticPrototypeProperty.errors.txt b/tests/baselines/reference/staticPrototypeProperty.errors.txt index c3f5cb99c96..b2f36a40bed 100644 --- a/tests/baselines/reference/staticPrototypeProperty.errors.txt +++ b/tests/baselines/reference/staticPrototypeProperty.errors.txt @@ -1,13 +1,19 @@ tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2300: Duplicate identifier 'prototype'. +tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. -==== tests/cases/compiler/staticPrototypeProperty.ts (1 errors) ==== +==== tests/cases/compiler/staticPrototypeProperty.ts (3 errors) ==== class C { static prototype() { } ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. } class C2 { static prototype; + ~~~~~~~~~ +!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. } \ No newline at end of file diff --git a/tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts b/tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts index c8ebc312104..aa78d4333c6 100644 --- a/tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts +++ b/tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts @@ -1,20 +1,20 @@ interface A { - name(); + prop(); } class B { - public name() { } + public prop() { } } class C { - public static name() { } + public static prop() { } } var a: A = new B(); -a = new C(); // error name is missing -a = B; // error name is missing +a = new C(); // error prop is missing +a = B; // error prop is missing a = C; -var b: B = new C(); // error name is missing -b = B; // error name is missing +var b: B = new C(); // error prop is missing +b = B; // error prop is missing b = C; b = a; diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts index 0f260673d9d..5eb09ddb2d3 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts @@ -1,26 +1,56 @@ // @target: es5 // static name -class A { +class StaticName { static name: number; // error name: string; // ok } -class B { +class StaticNameFn { static name() {} // error name() {} // ok } - -// static length... -class C { +class StaticLength { static length: number; // error length: string; // ok } -class D { +class StaticLengthFn { static length() {} // error length() {} // ok } + +class StaticPrototype { + static prototype: number; // error + prototype: string; // ok +} + +class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok +} + + +class StaticCaller { + static caller: number; // error + caller: string; // ok +} + +class StaticCallerFn { + static caller() {} // error + caller() {} // ok +} + + +class StaticArguments { + static arguments: number; // error + arguments: string; // ok +} + +class StaticArgumentsFn { + static arguments() {} // error + arguments() {} // ok +} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts index 47c7dbbde25..2122e183ff2 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts @@ -1,25 +1,56 @@ // @target: es6 -// static name -class A { - static name: string; // ok +class StaticName { + static name: number; // ok name: string; // ok } -class B { - static name() {}; // ok - name() {}; // ok +class StaticNameFn { + static name() {} // ok + name() {} // ok } -// static length -class C { +class StaticLength { static length: number; // ok length: string; // ok } -class D { +class StaticLengthFn { static length() {} // ok length() {} // ok } + + +class StaticPrototype { + static prototype: number; // error + prototype: string; // ok +} + +class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok +} + + +class StaticCaller { + static caller: number; // // error + caller: string; // ok +} + +class StaticCallerFn { + static caller() {} // // error + caller() {} // ok +} + + +class StaticArguments { + static arguments: number; // // error + arguments: string; // ok +} + +class StaticArgumentsFn { + static arguments() {} // // error + arguments() {} // ok +} From 2bb4abce47c36f77abb59770e17a1f1ff59b4b42 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 17 Oct 2016 09:12:08 -0700 Subject: [PATCH 008/175] Use collator when making comparison as it is more performance than String.prototype.localeCompare --- src/compiler/core.ts | 13 +++++++++---- src/services/navigationBar.ts | 22 +--------------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index befa30b6006..f34e9af58ba 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -21,7 +21,9 @@ namespace ts { const createObject = Object.create; // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; + export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(/*locales*/ undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". + export const localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; export function createMap(template?: MapLike): Map { const map: Map = createObject(null); // tslint:disable-line:no-null-keyword @@ -1050,9 +1052,12 @@ namespace ts { if (a === undefined) return Comparison.LessThan; if (b === undefined) return Comparison.GreaterThan; if (ignoreCase) { - if (collator && String.prototype.localeCompare) { - // accent means a ≠ b, a ≠ á, a = A - const result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); + // Checking if "collator exists indicates that Intl is available. + // We still have to check if "collator.compare" is correct. If it is not, use "String.localeComapre" + if (collator) { + const result = localeCompareIsCorrect ? + collator.compare(a, b) : + a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); // accent means a ≠ b, a ≠ á, a = A return result < 0 ? Comparison.LessThan : result > 0 ? Comparison.GreaterThan : Comparison.EqualTo; } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 7b4fb8cdba6..ce47d814e51 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -322,7 +322,7 @@ namespace ts.NavigationBar { function compareChildren(child1: NavigationBarNode, child2: NavigationBarNode): number { const name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - const cmp = localeCompareFix(name1, name2); + const cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { @@ -330,26 +330,6 @@ namespace ts.NavigationBar { } } - // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - const localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - const localeCompareFix: (a: string, b: string) => number = localeCompareIsCorrect ? collator.compare : function(a, b) { - // This isn't perfect, but it passes all of our tests. - for (let i = 0; i < Math.min(a.length, b.length); i++) { - const chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - const cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; - /** * This differs from getItemName because this is just used for sorting. * We only sort nodes by name that have a more-or-less "direct" name, as opposed to `new()` and the like. From 45e8a5b54d0e3fe8deb1f412436a9defad0ff04e Mon Sep 17 00:00:00 2001 From: about-code Date: Mon, 17 Oct 2016 19:22:40 +0200 Subject: [PATCH 009/175] Accepting new baseline. Format code to fit linter rules. --- src/compiler/checker.ts | 53 ++++++++++--------- .../propertyNamedPrototype.errors.txt | 4 +- .../staticPropertyNameConflictsEs5.errors.txt | 40 +++++++------- .../staticPropertyNameConflictsEs6.errors.txt | 24 ++++----- .../staticPrototypeProperty.errors.txt | 8 +-- 5 files changed, 66 insertions(+), 63 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2412faed6ad..9e8c92309b0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14554,43 +14554,46 @@ namespace ts { // Static members may conflict with non-configurable non-writable built-in Function.prototype properties // see https://github.com/microsoft/typescript/issues/442. - function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { + function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { const es5_descriptors: PropertyDescriptorMap = { // see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 // see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 - "name": {configurable: false, writable: false}, - "length": {configurable: false, writable: false}, - "prototype": {configurable: false, writable: false}, + "name": { configurable: false, writable: false }, + "length": { configurable: false, writable: false }, + "prototype": { configurable: false, writable: false }, // see https://github.com/microsoft/typescript/issues/442 - "caller": {configurable: false, writable: false}, - "arguments": {configurable: false, writable: false} - }; + "caller": { configurable: false, writable: false }, + "arguments": { configurable: false, writable: false } + }; const post_es5_descriptors: PropertyDescriptorMap = { // see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor // see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances - "name": {configurable: true, writable: false}, - "length": {configurable: true, writable: false}, - "prototype": {configurable: false, writable: false}, - "caller": {configurable: false, writable: false}, - "arguments": {configurable: false, writable: false} + "name": { configurable: true, writable: false }, + "length": { configurable: true, writable: false }, + "prototype": { configurable: false, writable: false }, + "caller": { configurable: false, writable: false }, + "arguments": { configurable: false, writable: false } }; const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; const className = getSymbolOfNode(node).name; - - for (let member of node.members) { - let isStatic = forEach(member.modifiers, (m:Modifier) => m.kind === SyntaxKind.StaticKeyword); + + for (const member of node.members) { + const isStatic = forEach(member.modifiers, (m: Modifier) => m.kind === SyntaxKind.StaticKeyword); if (isStatic) { - let memberNameNode = member.name; - let memberName = getPropertyNameForPropertyNameNode(memberNameNode); - let descriptor: PropertyDescriptor = null; - if (languageVersion <= ScriptTarget.ES5) { - descriptor = es5_descriptors.hasOwnProperty(memberName) ? es5_descriptors[memberName] : null; - } else if (languageVersion > ScriptTarget.ES5) { - descriptor = post_es5_descriptors.hasOwnProperty(memberName) ? post_es5_descriptors[memberName] : null; - } - if (descriptor && descriptor.configurable === false && descriptor.writable === false) { - error(memberNameNode, message, memberName, className); + const memberNameNode = member.name; + if (memberNameNode) { + const memberName = getPropertyNameForPropertyNameNode(memberNameNode); + let descriptor: PropertyDescriptor = undefined; + if (languageVersion <= ScriptTarget.ES5) { + descriptor = es5_descriptors.hasOwnProperty(memberName) ? es5_descriptors[memberName] : undefined; + } + else if (languageVersion > ScriptTarget.ES5) { + descriptor = post_es5_descriptors.hasOwnProperty(memberName) ? post_es5_descriptors[memberName] : undefined; + } + if (descriptor && descriptor.configurable === false && descriptor.writable === false) { + error(memberNameNode, message, memberName, className); + } } } } diff --git a/tests/baselines/reference/propertyNamedPrototype.errors.txt b/tests/baselines/reference/propertyNamedPrototype.errors.txt index 6ddd8390720..2c0c8f30f76 100644 --- a/tests/baselines/reference/propertyNamedPrototype.errors.txt +++ b/tests/baselines/reference/propertyNamedPrototype.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts(3,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts(3,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototyp prototype: number; // ok static prototype: C; // error ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt index 182b1628522..5c3f3b3f7dc 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt +++ b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(4,12): error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(9,12): error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(15,12): error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(20,12): error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(26,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(4,12): error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(9,12): error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(15,12): error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(20,12): error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(26,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2300: Duplicate identifier 'prototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(37,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(42,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(48,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(53,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(37,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(42,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(48,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(53,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts (11 errors) ==== @@ -17,14 +17,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticName { static name: number; // error ~~~~ -!!! error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +!!! error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. name: string; // ok } class StaticNameFn { static name() {} // error ~~~~ -!!! error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +!!! error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. name() {} // ok } @@ -32,14 +32,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticLength { static length: number; // error ~~~~~~ -!!! error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +!!! error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. length: string; // ok } class StaticLengthFn { static length() {} // error ~~~~~~ -!!! error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +!!! error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. length() {} // ok } @@ -47,7 +47,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticPrototype { static prototype: number; // error ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. prototype: string; // ok } @@ -56,7 +56,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. prototype() {} // ok } @@ -64,14 +64,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticCaller { static caller: number; // error ~~~~~~ -!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. caller: string; // ok } class StaticCallerFn { static caller() {} // error ~~~~~~ -!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. caller() {} // ok } @@ -79,14 +79,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticArguments { static arguments: number; // error ~~~~~~~~~ -!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. arguments: string; // ok } class StaticArgumentsFn { static arguments() {} // error ~~~~~~~~~ -!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. arguments() {} // ok } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt index b76b7e02b76..0c65494c7bc 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2300: Duplicate identifier 'prototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(42,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(53,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(42,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(53,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (7 errors) ==== @@ -35,7 +35,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticPrototype { static prototype: number; // error ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. prototype: string; // ok } @@ -44,7 +44,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. prototype() {} // ok } @@ -52,14 +52,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticCaller { static caller: number; // // error ~~~~~~ -!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. caller: string; // ok } class StaticCallerFn { static caller() {} // // error ~~~~~~ -!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. caller() {} // ok } @@ -67,14 +67,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticArguments { static arguments: number; // // error ~~~~~~~~~ -!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. arguments: string; // ok } class StaticArgumentsFn { static arguments() {} // // error ~~~~~~~~~ -!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. arguments() {} // ok } \ No newline at end of file diff --git a/tests/baselines/reference/staticPrototypeProperty.errors.txt b/tests/baselines/reference/staticPrototypeProperty.errors.txt index b2f36a40bed..44b6980cb91 100644 --- a/tests/baselines/reference/staticPrototypeProperty.errors.txt +++ b/tests/baselines/reference/staticPrototypeProperty.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2300: Duplicate identifier 'prototype'. -tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. -tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. +tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. ==== tests/cases/compiler/staticPrototypeProperty.ts (3 errors) ==== @@ -9,11 +9,11 @@ tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2692: Static prop ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. } class C2 { static prototype; ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. } \ No newline at end of file From 189dbddb101a0d5acaa612013d8cdd07ece78344 Mon Sep 17 00:00:00 2001 From: about-code Date: Sat, 5 Nov 2016 18:42:53 +0100 Subject: [PATCH 010/175] Accept baseline tests. Fixing `diagnosticMessages.json` (merge result not included in prior commit). --- src/compiler/diagnosticMessages.json | 12 ++---- .../propertyNamedPrototype.errors.txt | 4 +- .../staticPropertyNameConflictsEs5.errors.txt | 40 +++++++++---------- .../staticPropertyNameConflictsEs6.errors.txt | 32 +++++++-------- .../staticPropertyNameConflictsEs6.js | 12 +++--- .../staticPrototypeProperty.errors.txt | 8 ++-- ...ariableDeclarationInStrictMode1.errors.txt | 2 +- .../staticPropertyNameConflictsEs6.ts | 8 ++-- 8 files changed, 57 insertions(+), 61 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 77df2489fe5..4bb683865a8 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1979,18 +1979,14 @@ "category": "Error", "code": 2696 }, -<<<<<<< HEAD - "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'.": { - "category": "Error", - "code": 2699 - }, -======= "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": { "category": "Error", "code": 2697 }, - ->>>>>>> upstream/master + "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'.": { + "category": "Error", + "code": 2699 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/propertyNamedPrototype.errors.txt b/tests/baselines/reference/propertyNamedPrototype.errors.txt index 2c0c8f30f76..d80e1c95c8d 100644 --- a/tests/baselines/reference/propertyNamedPrototype.errors.txt +++ b/tests/baselines/reference/propertyNamedPrototype.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts(3,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts(3,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototyp prototype: number; // ok static prototype: C; // error ~~~~~~~~~ -!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt index 5c3f3b3f7dc..004365d3e76 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt +++ b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(4,12): error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(9,12): error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(15,12): error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(20,12): error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(26,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(4,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(9,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(15,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(20,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(26,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2300: Duplicate identifier 'prototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(37,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(42,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(48,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(53,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(37,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(42,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(48,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(53,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts (11 errors) ==== @@ -17,14 +17,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticName { static name: number; // error ~~~~ -!!! error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. name: string; // ok } class StaticNameFn { static name() {} // error ~~~~ -!!! error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. name() {} // ok } @@ -32,14 +32,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticLength { static length: number; // error ~~~~~~ -!!! error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. length: string; // ok } class StaticLengthFn { static length() {} // error ~~~~~~ -!!! error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. length() {} // ok } @@ -47,7 +47,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticPrototype { static prototype: number; // error ~~~~~~~~~ -!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. prototype: string; // ok } @@ -56,7 +56,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. prototype() {} // ok } @@ -64,14 +64,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticCaller { static caller: number; // error ~~~~~~ -!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. caller: string; // ok } class StaticCallerFn { static caller() {} // error ~~~~~~ -!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. caller() {} // ok } @@ -79,14 +79,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticArguments { static arguments: number; // error ~~~~~~~~~ -!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. arguments: string; // ok } class StaticArgumentsFn { static arguments() {} // error ~~~~~~~~~ -!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. arguments() {} // ok } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt index 0c65494c7bc..ef83151aa3d 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2300: Duplicate identifier 'prototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(42,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(53,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(42,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(53,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (7 errors) ==== @@ -35,7 +35,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticPrototype { static prototype: number; // error ~~~~~~~~~ -!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. prototype: string; // ok } @@ -44,37 +44,37 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. prototype() {} // ok } class StaticCaller { - static caller: number; // // error + static caller: number; // error ~~~~~~ -!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. caller: string; // ok } class StaticCallerFn { - static caller() {} // // error + static caller() {} // error ~~~~~~ -!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. caller() {} // ok } class StaticArguments { - static arguments: number; // // error + static arguments: number; // error ~~~~~~~~~ -!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. arguments: string; // ok } class StaticArgumentsFn { - static arguments() {} // // error + static arguments() {} // error ~~~~~~~~~ -!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. arguments() {} // ok } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.js b/tests/baselines/reference/staticPropertyNameConflictsEs6.js index 67756c37a92..48e8b7a063d 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.js +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.js @@ -35,23 +35,23 @@ class StaticPrototypeFn { class StaticCaller { - static caller: number; // // error + static caller: number; // error caller: string; // ok } class StaticCallerFn { - static caller() {} // // error + static caller() {} // error caller() {} // ok } class StaticArguments { - static arguments: number; // // error + static arguments: number; // error arguments: string; // ok } class StaticArgumentsFn { - static arguments() {} // // error + static arguments() {} // error arguments() {} // ok } @@ -78,12 +78,12 @@ class StaticPrototypeFn { class StaticCaller { } class StaticCallerFn { - static caller() { } // // error + static caller() { } // error caller() { } // ok } class StaticArguments { } class StaticArgumentsFn { - static arguments() { } // // error + static arguments() { } // error arguments() { } // ok } diff --git a/tests/baselines/reference/staticPrototypeProperty.errors.txt b/tests/baselines/reference/staticPrototypeProperty.errors.txt index 44b6980cb91..c131b7a774d 100644 --- a/tests/baselines/reference/staticPrototypeProperty.errors.txt +++ b/tests/baselines/reference/staticPrototypeProperty.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2300: Duplicate identifier 'prototype'. -tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. -tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. +tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. ==== tests/cases/compiler/staticPrototypeProperty.ts (3 errors) ==== @@ -9,11 +9,11 @@ tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2697: Static prop ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. } class C2 { static prototype; ~~~~~~~~~ -!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. } \ No newline at end of file diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt index 46782aaa1d6..9dd9a8d41a1 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(28,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/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts index 2122e183ff2..412833791b4 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts @@ -35,22 +35,22 @@ class StaticPrototypeFn { class StaticCaller { - static caller: number; // // error + static caller: number; // error caller: string; // ok } class StaticCallerFn { - static caller() {} // // error + static caller() {} // error caller() {} // ok } class StaticArguments { - static arguments: number; // // error + static arguments: number; // error arguments: string; // ok } class StaticArgumentsFn { - static arguments() {} // // error + static arguments() {} // error arguments() {} // ok } From d58b5c807cffd71e65d6c26ac45e1858427f062c Mon Sep 17 00:00:00 2001 From: about-code Date: Sun, 6 Nov 2016 00:36:41 +0100 Subject: [PATCH 011/175] Fixing wrong line number in tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt after rebuilding and testing compiler. --- .../reference/variableDeclarationInStrictMode1.errors.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt index 9dd9a8d41a1..46782aaa1d6 100644 --- a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt +++ b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt @@ -1,4 +1,4 @@ -lib.d.ts(28,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'. From d9a46e1ae6877e4fe806fe2592d043d330ea2893 Mon Sep 17 00:00:00 2001 From: about-code Date: Sun, 6 Nov 2016 17:59:38 +0100 Subject: [PATCH 012/175] Allowing `static arguments()` and `static caller()` for target `"es6"`. Disallow non-function properties `static arguments` and `static caller`, though. --- src/compiler/checker.ts | 64 +++++++++---------- .../staticPropertyNameConflictsEs6.errors.txt | 12 +--- .../staticPropertyNameConflictsEs6.js | 8 +-- .../staticPropertyNameConflictsEs6.ts | 4 +- 4 files changed, 38 insertions(+), 50 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6524a69f13f..d756f215ac3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14764,49 +14764,43 @@ namespace ts { } } - // Static members may conflict with non-configurable non-writable built-in Function.prototype properties + // Static members may conflict with non-configurable non-writable built-in Function object properties // see https://github.com/microsoft/typescript/issues/442. function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { - const es5_descriptors: PropertyDescriptorMap = { - // see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 - // see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 - "name": { configurable: false, writable: false }, - "length": { configurable: false, writable: false }, - "prototype": { configurable: false, writable: false }, - - // see https://github.com/microsoft/typescript/issues/442 - "caller": { configurable: false, writable: false }, - "arguments": { configurable: false, writable: false } - }; - const post_es5_descriptors: PropertyDescriptorMap = { - // see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor - // see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances - "name": { configurable: true, writable: false }, - "length": { configurable: true, writable: false }, - "prototype": { configurable: false, writable: false }, - "caller": { configurable: false, writable: false }, - "arguments": { configurable: false, writable: false } - }; const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; const className = getSymbolOfNode(node).name; - for (const member of node.members) { - const isStatic = forEach(member.modifiers, (m: Modifier) => m.kind === SyntaxKind.StaticKeyword); - if (isStatic) { - const memberNameNode = member.name; - if (memberNameNode) { - const memberName = getPropertyNameForPropertyNameNode(memberNameNode); - let descriptor: PropertyDescriptor = undefined; - if (languageVersion <= ScriptTarget.ES5) { - descriptor = es5_descriptors.hasOwnProperty(memberName) ? es5_descriptors[memberName] : undefined; - } - else if (languageVersion > ScriptTarget.ES5) { - descriptor = post_es5_descriptors.hasOwnProperty(memberName) ? post_es5_descriptors[memberName] : undefined; - } - if (descriptor && descriptor.configurable === false && descriptor.writable === false) { + const isStatic = forEach(member.modifiers, (m: Modifier) => m.kind === SyntaxKind.StaticKeyword); + const isMethod = member.kind === SyntaxKind.MethodDeclaration; + const memberNameNode = member.name; + if (isStatic && memberNameNode) { + const memberName = getPropertyNameForPropertyNameNode(memberNameNode); + if (languageVersion <= ScriptTarget.ES5) { // ES3, ES5 + // see also http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 + // see also http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 + if (memberName === "prototype" || + memberName === "name" || + memberName === "length" || + memberName === "caller" || + memberName === "arguments" + ) { error(memberNameNode, message, memberName, className); } } + else { // ES6+ + // see also http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor + // see also http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances + if (memberName === "prototype") { + error(memberNameNode, message, memberName, className); + } + else if (( + memberName === "caller" || + memberName === "arguments" ) && + isMethod === false + ) { + error(memberNameNode, message, memberName, className); + } + } } } } diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt index ef83151aa3d..b73b01abbbe 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt @@ -2,12 +2,10 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2300: Duplicate identifier 'prototype'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(42,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(53,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. -==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (7 errors) ==== +==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (5 errors) ==== class StaticName { @@ -57,9 +55,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon } class StaticCallerFn { - static caller() {} // error - ~~~~~~ -!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. + static caller() {} // ok caller() {} // ok } @@ -72,9 +68,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon } class StaticArgumentsFn { - static arguments() {} // error - ~~~~~~~~~ -!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + static arguments() {} // ok arguments() {} // ok } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.js b/tests/baselines/reference/staticPropertyNameConflictsEs6.js index 48e8b7a063d..8d96c73d4c5 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.js +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.js @@ -40,7 +40,7 @@ class StaticCaller { } class StaticCallerFn { - static caller() {} // error + static caller() {} // ok caller() {} // ok } @@ -51,7 +51,7 @@ class StaticArguments { } class StaticArgumentsFn { - static arguments() {} // error + static arguments() {} // ok arguments() {} // ok } @@ -78,12 +78,12 @@ class StaticPrototypeFn { class StaticCaller { } class StaticCallerFn { - static caller() { } // error + static caller() { } // ok caller() { } // ok } class StaticArguments { } class StaticArgumentsFn { - static arguments() { } // error + static arguments() { } // ok arguments() { } // ok } diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts index 412833791b4..01db0c27872 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts @@ -40,7 +40,7 @@ class StaticCaller { } class StaticCallerFn { - static caller() {} // error + static caller() {} // ok caller() {} // ok } @@ -51,6 +51,6 @@ class StaticArguments { } class StaticArgumentsFn { - static arguments() {} // error + static arguments() {} // ok arguments() {} // ok } From b623f3771e91f5fe31c498c9a5defc4172b567bd Mon Sep 17 00:00:00 2001 From: about-code Date: Wed, 9 Nov 2016 21:08:56 +0100 Subject: [PATCH 013/175] Fix #442: (es3, es5, es6+) Show compiler errors for conflicting properties. --- src/compiler/checker.ts | 6 ++++-- .../staticPropertyNameConflictsEs6.errors.txt | 14 ++++++++++---- .../reference/staticPropertyNameConflictsEs6.js | 6 +++--- .../staticPropertyNameConflictsEs6.ts | 6 +++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d756f215ac3..de82ee004e8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14794,11 +14794,13 @@ namespace ts { error(memberNameNode, message, memberName, className); } else if (( + memberName === "name" || + memberName === "length" || memberName === "caller" || - memberName === "arguments" ) && + memberName === "arguments") && isMethod === false ) { - error(memberNameNode, message, memberName, className); + error(memberNameNode, message, memberName, className); } } } diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt index b73b01abbbe..607735bb12f 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt @@ -1,3 +1,5 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(4,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(15,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2300: Duplicate identifier 'prototype'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. @@ -5,22 +7,26 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (5 errors) ==== +==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (7 errors) ==== class StaticName { - static name: number; // ok + static name: number; // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. name: string; // ok } class StaticNameFn { - static name() {} // ok + static name() {} // ok name() {} // ok } class StaticLength { - static length: number; // ok + static length: number; // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. length: string; // ok } diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.js b/tests/baselines/reference/staticPropertyNameConflictsEs6.js index 8d96c73d4c5..7adef10b141 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.js +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.js @@ -2,18 +2,18 @@ class StaticName { - static name: number; // ok + static name: number; // error name: string; // ok } class StaticNameFn { - static name() {} // ok + static name() {} // ok name() {} // ok } class StaticLength { - static length: number; // ok + static length: number; // error length: string; // ok } diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts index 01db0c27872..1b93e98dae8 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts @@ -2,18 +2,18 @@ class StaticName { - static name: number; // ok + static name: number; // error name: string; // ok } class StaticNameFn { - static name() {} // ok + static name() {} // ok name() {} // ok } class StaticLength { - static length: number; // ok + static length: number; // error length: string; // ok } From ca9f599563e6f089d34284efbf01ef46040ad7d8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 5 Dec 2016 09:57:11 -0800 Subject: [PATCH 014/175] Property access for string index signatures --- src/compiler/checker.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 903c8cfda1c..4a575e014cd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12223,6 +12223,10 @@ namespace ts { } const prop = getPropertyOfType(apparentType, right.text); if (!prop) { + const stringIndexType = getIndexTypeOfType(apparentType, IndexKind.String); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ? apparentType : type); } From a90d63a414473fb1f9faf8866e7e1b75fbbfe6f7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 5 Dec 2016 09:58:09 -0800 Subject: [PATCH 015/175] Add tests for property access w/string index sigs --- .../propertyAccessStringIndexSignature.ts | 11 +++++++++++ ...ropertyAccessStringIndexSignatureNoImplicitAny.ts | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignature.ts create mode 100644 tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts diff --git a/tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignature.ts b/tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignature.ts new file mode 100644 index 00000000000..7faf758bc9f --- /dev/null +++ b/tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignature.ts @@ -0,0 +1,11 @@ +interface Flags { [name: string]: boolean }; +let flags: Flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; + +interface Empty { } +let empty: Empty; +empty.nope; +empty["that's ok"]; diff --git a/tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts b/tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts new file mode 100644 index 00000000000..bfb64c6098a --- /dev/null +++ b/tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts @@ -0,0 +1,12 @@ +// @noImplicitAny: true +interface Flags { [name: string]: boolean } +let flags: Flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; + +interface Empty { } +let empty: Empty; +empty.nope; +empty["not allowed either"]; From fe3ed12a20ecc17ed48a99f4c777ebd1f8979ff9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 5 Dec 2016 09:58:33 -0800 Subject: [PATCH 016/175] Update tests and baselines --- tests/baselines/reference/objectRest.js | 4 ++-- tests/baselines/reference/objectRest.symbols | 2 +- tests/baselines/reference/objectRest.types | 10 ++++---- .../reference/objectRestNegative.errors.txt | 7 +----- .../baselines/reference/objectRestNegative.js | 6 ----- ...pertyAccessStringIndexSignature.errors.txt | 18 ++++++++++++++ .../propertyAccessStringIndexSignature.js | 24 +++++++++++++++++++ ...ringIndexSignatureNoImplicitAny.errors.txt | 21 ++++++++++++++++ ...AccessStringIndexSignatureNoImplicitAny.js | 23 ++++++++++++++++++ .../conformance/types/rest/objectRest.ts | 2 +- .../types/rest/objectRestNegative.ts | 2 -- 11 files changed, 96 insertions(+), 23 deletions(-) create mode 100644 tests/baselines/reference/propertyAccessStringIndexSignature.errors.txt create mode 100644 tests/baselines/reference/propertyAccessStringIndexSignature.js create mode 100644 tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.errors.txt create mode 100644 tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.js diff --git a/tests/baselines/reference/objectRest.js b/tests/baselines/reference/objectRest.js index 48a1bf8daf8..8060098ba4b 100644 --- a/tests/baselines/reference/objectRest.js +++ b/tests/baselines/reference/objectRest.js @@ -37,7 +37,7 @@ let computed2 = 'a'; var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; ({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; +var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; //// [objectRest.js] @@ -80,6 +80,6 @@ var _g = computed, stillNotGreat = o[_g], _h = computed2, soSo = o[_h], o = __re (_j = computed, stillNotGreat = o[_j], _k = computed2, soSo = o[_k], o = __rest(o, [typeof _j === "symbol" ? _j : _j + "", typeof _k === "symbol" ? _k : _k + ""])); var noContextualType = (_a) => { var { aNumber = 12 } = _a, notEmptyObject = __rest(_a, ["aNumber"]); - return aNumber + notEmptyObject['anythingGoes']; + return aNumber + notEmptyObject.anythingGoes; }; var _d, _f, _j, _k; diff --git a/tests/baselines/reference/objectRest.symbols b/tests/baselines/reference/objectRest.symbols index 46309392135..5bacb33f5da 100644 --- a/tests/baselines/reference/objectRest.symbols +++ b/tests/baselines/reference/objectRest.symbols @@ -169,7 +169,7 @@ var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; >o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) >o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; +var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; >noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 38, 3)) >aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25)) >notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39)) diff --git a/tests/baselines/reference/objectRest.types b/tests/baselines/reference/objectRest.types index 1dc05741713..01a85b50348 100644 --- a/tests/baselines/reference/objectRest.types +++ b/tests/baselines/reference/objectRest.types @@ -195,15 +195,15 @@ var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; >o : { a: number; b: string; } >o : { a: number; b: string; } -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; +var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; >noContextualType : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any ->({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes'] : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any +>({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any >aNumber : number >12 : 12 >notEmptyObject : { [x: string]: any; } ->aNumber + notEmptyObject['anythingGoes'] : any +>aNumber + notEmptyObject.anythingGoes : any >aNumber : number ->notEmptyObject['anythingGoes'] : any +>notEmptyObject.anythingGoes : any >notEmptyObject : { [x: string]: any; } ->'anythingGoes' : "anythingGoes" +>anythingGoes : any diff --git a/tests/baselines/reference/objectRestNegative.errors.txt b/tests/baselines/reference/objectRestNegative.errors.txt index 6e65af4bdc1..56de8aaccb6 100644 --- a/tests/baselines/reference/objectRestNegative.errors.txt +++ b/tests/baselines/reference/objectRestNegative.errors.txt @@ -7,10 +7,9 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(11,30): error TS7008: M tests/cases/conformance/types/rest/objectRestNegative.ts(11,33): error TS7008: Member 'y' implicitly has an 'any' type. tests/cases/conformance/types/rest/objectRestNegative.ts(12,17): error TS2700: Rest types may only be created from object types. tests/cases/conformance/types/rest/objectRestNegative.ts(17,9): error TS2701: The target of an object rest assignment must be a variable or a property access. -tests/cases/conformance/types/rest/objectRestNegative.ts(19,90): error TS2339: Property 'anythingGoes' does not exist on type '{ [x: string]: any; }'. -==== tests/cases/conformance/types/rest/objectRestNegative.ts (8 errors) ==== +==== tests/cases/conformance/types/rest/objectRestNegative.ts (7 errors) ==== let o = { a: 1, b: 'no' }; var { ...mustBeLast, a } = o; ~~~~~~~~~~ @@ -44,8 +43,4 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(19,90): error TS2339: P ({a, ...rest.b + rest.b} = o); ~~~~~~~~~~~~~~~ !!! error TS2701: The target of an object rest assignment must be a variable or a property access. - - var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; - ~~~~~~~~~~~~ -!!! error TS2339: Property 'anythingGoes' does not exist on type '{ [x: string]: any; }'. \ No newline at end of file diff --git a/tests/baselines/reference/objectRestNegative.js b/tests/baselines/reference/objectRestNegative.js index 19559e865f2..915e0a0e867 100644 --- a/tests/baselines/reference/objectRestNegative.js +++ b/tests/baselines/reference/objectRestNegative.js @@ -16,8 +16,6 @@ function generic(t: T) { let rest: { b: string } ({a, ...rest.b + rest.b} = o); - -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; //// [objectRestNegative.js] @@ -44,7 +42,3 @@ function generic(t) { } var rest; (a = o.a, o, rest.b + rest.b = __rest(o, ["a"])); -var noContextualType = function (_a) { - var _b = _a.aNumber, aNumber = _b === void 0 ? 12 : _b, notEmptyObject = __rest(_a, ["aNumber"]); - return aNumber + notEmptyObject.anythingGoes; -}; diff --git a/tests/baselines/reference/propertyAccessStringIndexSignature.errors.txt b/tests/baselines/reference/propertyAccessStringIndexSignature.errors.txt new file mode 100644 index 00000000000..d376551d91d --- /dev/null +++ b/tests/baselines/reference/propertyAccessStringIndexSignature.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignature.ts(10,7): error TS2339: Property 'nope' does not exist on type 'Empty'. + + +==== tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignature.ts (1 errors) ==== + interface Flags { [name: string]: boolean }; + let flags: Flags; + flags.b; + flags.f; + flags.isNotNecessarilyNeverFalse; + flags['this is fine']; + + interface Empty { } + let empty: Empty; + empty.nope; + ~~~~ +!!! error TS2339: Property 'nope' does not exist on type 'Empty'. + empty["that's ok"]; + \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessStringIndexSignature.js b/tests/baselines/reference/propertyAccessStringIndexSignature.js new file mode 100644 index 00000000000..d37a8bfea0e --- /dev/null +++ b/tests/baselines/reference/propertyAccessStringIndexSignature.js @@ -0,0 +1,24 @@ +//// [propertyAccessStringIndexSignature.ts] +interface Flags { [name: string]: boolean }; +let flags: Flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; + +interface Empty { } +let empty: Empty; +empty.nope; +empty["that's ok"]; + + +//// [propertyAccessStringIndexSignature.js] +; +var flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; +var empty; +empty.nope; +empty["that's ok"]; diff --git a/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.errors.txt b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.errors.txt new file mode 100644 index 00000000000..d5fda181096 --- /dev/null +++ b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts(10,7): error TS2339: Property 'nope' does not exist on type 'Empty'. +tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts(11,1): error TS7017: Element implicitly has an 'any' type because type 'Empty' has no index signature. + + +==== tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts (2 errors) ==== + interface Flags { [name: string]: boolean } + let flags: Flags; + flags.b; + flags.f; + flags.isNotNecessarilyNeverFalse; + flags['this is fine']; + + interface Empty { } + let empty: Empty; + empty.nope; + ~~~~ +!!! error TS2339: Property 'nope' does not exist on type 'Empty'. + empty["not allowed either"]; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type 'Empty' has no index signature. + \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.js b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.js new file mode 100644 index 00000000000..3c2abcc182b --- /dev/null +++ b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.js @@ -0,0 +1,23 @@ +//// [propertyAccessStringIndexSignatureNoImplicitAny.ts] +interface Flags { [name: string]: boolean } +let flags: Flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; + +interface Empty { } +let empty: Empty; +empty.nope; +empty["not allowed either"]; + + +//// [propertyAccessStringIndexSignatureNoImplicitAny.js] +var flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; +var empty; +empty.nope; +empty["not allowed either"]; diff --git a/tests/cases/conformance/types/rest/objectRest.ts b/tests/cases/conformance/types/rest/objectRest.ts index 2fba5d0b6dc..5891ce2414b 100644 --- a/tests/cases/conformance/types/rest/objectRest.ts +++ b/tests/cases/conformance/types/rest/objectRest.ts @@ -37,4 +37,4 @@ let computed2 = 'a'; var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; ({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; +var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; diff --git a/tests/cases/conformance/types/rest/objectRestNegative.ts b/tests/cases/conformance/types/rest/objectRestNegative.ts index 4f4667fe65a..13d214e453d 100644 --- a/tests/cases/conformance/types/rest/objectRestNegative.ts +++ b/tests/cases/conformance/types/rest/objectRestNegative.ts @@ -16,5 +16,3 @@ function generic(t: T) { let rest: { b: string } ({a, ...rest.b + rest.b} = o); - -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; From 157a9b02fc5e9aa825697bd7779145eded74cdf5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 5 Dec 2016 08:43:16 -0800 Subject: [PATCH 017/175] Properly determine whether an augmentation is a ValueModule or NamespaceModule --- src/compiler/binder.ts | 19 ++++++++++------ .../reference/augmentExportEquals7.errors.txt | 22 +++++++++++++++++++ tests/cases/compiler/augmentExportEquals7.ts | 10 +++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/augmentExportEquals7.errors.txt create mode 100644 tests/cases/compiler/augmentExportEquals7.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a6f5993f6c8..e00e9294529 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1509,7 +1509,7 @@ namespace ts { errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); + declareModuleSymbol(node); } else { let pattern: Pattern | undefined; @@ -1531,12 +1531,8 @@ namespace ts { } } else { - const state = getModuleInstanceState(node); - if (state === ModuleInstanceState.NonInstantiated) { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); - } - else { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + const state = declareModuleSymbol(node); + if (state !== ModuleInstanceState.NonInstantiated) { if (node.symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum)) { // if module was already merged with some function, class or non-const enum // treat is a non-const-enum-only @@ -1557,6 +1553,15 @@ namespace ts { } } + function declareModuleSymbol(node: ModuleDeclaration): ModuleInstanceState { + const state = getModuleInstanceState(node); + const instantiated = state !== ModuleInstanceState.NonInstantiated; + declareSymbolAndAddToSymbolTable(node, + instantiated ? SymbolFlags.ValueModule : SymbolFlags.NamespaceModule, + instantiated ? SymbolFlags.ValueModuleExcludes : SymbolFlags.NamespaceModuleExcludes); + return state; + } + function bindFunctionOrConstructorType(node: SignatureDeclaration): void { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } diff --git a/tests/baselines/reference/augmentExportEquals7.errors.txt b/tests/baselines/reference/augmentExportEquals7.errors.txt new file mode 100644 index 00000000000..1cb9ddc041c --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals7.errors.txt @@ -0,0 +1,22 @@ +/node_modules/@types/lib-extender/index.d.ts(2,16): error TS2300: Duplicate identifier '"lib"'. +/node_modules/lib/index.d.ts(1,13): error TS2300: Duplicate identifier '"lib"'. +/node_modules/lib/index.d.ts(2,19): error TS2300: Duplicate identifier '"lib"'. + + +==== /node_modules/lib/index.d.ts (2 errors) ==== + declare var lib: () => void; + ~~~ +!!! error TS2300: Duplicate identifier '"lib"'. + declare namespace lib {} + ~~~ +!!! error TS2300: Duplicate identifier '"lib"'. + export = lib; + +==== /node_modules/@types/lib-extender/index.d.ts (1 errors) ==== + import * as lib from "lib"; + declare module "lib" { + ~~~~~ +!!! error TS2300: Duplicate identifier '"lib"'. + export function fn(): void; + } + \ No newline at end of file diff --git a/tests/cases/compiler/augmentExportEquals7.ts b/tests/cases/compiler/augmentExportEquals7.ts new file mode 100644 index 00000000000..c287bcbe8c4 --- /dev/null +++ b/tests/cases/compiler/augmentExportEquals7.ts @@ -0,0 +1,10 @@ +// @Filename: /node_modules/lib/index.d.ts +declare var lib: () => void; +declare namespace lib {} +export = lib; + +// @Filename: /node_modules/@types/lib-extender/index.d.ts +import * as lib from "lib"; +declare module "lib" { + export function fn(): void; +} From 7beeb77201450aa8a95d494f3fde167c1fb9b550 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 5 Dec 2016 10:58:47 -0800 Subject: [PATCH 018/175] Update baseline --- .../reference/globalAugmentationModuleResolution.types | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/globalAugmentationModuleResolution.types b/tests/baselines/reference/globalAugmentationModuleResolution.types index c057ea2943d..75f23b0cd6b 100644 --- a/tests/baselines/reference/globalAugmentationModuleResolution.types +++ b/tests/baselines/reference/globalAugmentationModuleResolution.types @@ -3,7 +3,7 @@ export { }; declare global { ->global : any +>global : typeof global var x: number; >x : number From 39040f61540c2a2ec3cb9a9cc5c2920a3a0188fe Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 7 Dec 2016 13:13:21 -0800 Subject: [PATCH 019/175] Provide better error message --- src/compiler/checker.ts | 3 +++ src/compiler/diagnosticMessages.json | 4 ++++ .../reference/augmentExportEquals7.errors.txt | 12 +++--------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 903c8cfda1c..d2d4502c79d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -479,6 +479,9 @@ namespace ts { } recordMergedSymbol(target, source); } + else if (target.flags & SymbolFlags.NamespaceModule) { + error(source.valueDeclaration.name, Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { const message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4d42c77e566..19b297fd4a9 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1807,6 +1807,10 @@ "category": "Error", "code": 2608 }, + "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { + "category": "Error", + "code": 2649 + }, "Cannot emit namespaced JSX elements in React": { "category": "Error", "code": 2650 diff --git a/tests/baselines/reference/augmentExportEquals7.errors.txt b/tests/baselines/reference/augmentExportEquals7.errors.txt index 1cb9ddc041c..e13cf037023 100644 --- a/tests/baselines/reference/augmentExportEquals7.errors.txt +++ b/tests/baselines/reference/augmentExportEquals7.errors.txt @@ -1,22 +1,16 @@ -/node_modules/@types/lib-extender/index.d.ts(2,16): error TS2300: Duplicate identifier '"lib"'. -/node_modules/lib/index.d.ts(1,13): error TS2300: Duplicate identifier '"lib"'. -/node_modules/lib/index.d.ts(2,19): error TS2300: Duplicate identifier '"lib"'. +/node_modules/@types/lib-extender/index.d.ts(2,16): error TS2649: Cannot augment module 'lib' with value exports because it resolves to a non-module entity. -==== /node_modules/lib/index.d.ts (2 errors) ==== +==== /node_modules/lib/index.d.ts (0 errors) ==== declare var lib: () => void; - ~~~ -!!! error TS2300: Duplicate identifier '"lib"'. declare namespace lib {} - ~~~ -!!! error TS2300: Duplicate identifier '"lib"'. export = lib; ==== /node_modules/@types/lib-extender/index.d.ts (1 errors) ==== import * as lib from "lib"; declare module "lib" { ~~~~~ -!!! error TS2300: Duplicate identifier '"lib"'. +!!! error TS2649: Cannot augment module 'lib' with value exports because it resolves to a non-module entity. export function fn(): void; } \ No newline at end of file From 06b3ea98386a3650faf96f196c2081ae40e43bf7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 7 Dec 2016 13:14:00 -0800 Subject: [PATCH 020/175] instanceof RHS must be any, callable/constructable or Function subtype Also includes a fast-path for null and undefined even though they are technically Function subtypes. --- src/compiler/checker.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cdef31ee400..650279ad52f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14380,14 +14380,18 @@ namespace ts { } // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - // and the right operand to be of type Any or a subtype of the 'Function' interface type. + // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (isTypeOfKind(leftType, TypeFlags.Primitive)) { error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported - if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { + if (!(isTypeAny(rightType) || + rightType.flags & TypeFlags.Nullable || + getSignaturesOfType(rightType, SignatureKind.Call).length || + getSignaturesOfType(rightType, SignatureKind.Construct).length || + isTypeSubtypeOf(rightType, globalFunctionType))) { error(right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; From f15a7a3bacb765b100062fb9c261116ef12ed2af Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 7 Dec 2016 13:16:23 -0800 Subject: [PATCH 021/175] Test:instanceof allows callable/constructable RHS --- ...anceofOperatorWithInvalidStaticToString.js | 34 ++++++++++++ ...fOperatorWithInvalidStaticToString.symbols | 50 +++++++++++++++++ ...eofOperatorWithInvalidStaticToString.types | 53 +++++++++++++++++++ ...anceofOperatorWithInvalidStaticToString.ts | 21 ++++++++ 4 files changed, 158 insertions(+) create mode 100644 tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js create mode 100644 tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols create mode 100644 tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types create mode 100644 tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js new file mode 100644 index 00000000000..bf5a6f7bce1 --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js @@ -0,0 +1,34 @@ +//// [instanceofOperatorWithInvalidStaticToString.ts] +declare class StaticToString { + static toString(): void; +} + +function foo(staticToString: StaticToString) { + return staticToString instanceof StaticToString; +} + +declare class StaticToNumber { + static toNumber(): void; +} +function bar(staticToNumber: StaticToNumber) { + return staticToNumber instanceof StaticToNumber; +} + +declare class NormalToString { + toString(): void; +} +function baz(normal: NormalToString) { + return normal instanceof NormalToString; +} + + +//// [instanceofOperatorWithInvalidStaticToString.js] +function foo(staticToString) { + return staticToString instanceof StaticToString; +} +function bar(staticToNumber) { + return staticToNumber instanceof StaticToNumber; +} +function baz(normal) { + return normal instanceof NormalToString; +} diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols new file mode 100644 index 00000000000..4f4dbda611a --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts === +declare class StaticToString { +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) + + static toString(): void; +>toString : Symbol(StaticToString.toString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 30)) +} + +function foo(staticToString: StaticToString) { +>foo : Symbol(foo, Decl(instanceofOperatorWithInvalidStaticToString.ts, 2, 1)) +>staticToString : Symbol(staticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 4, 13)) +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) + + return staticToString instanceof StaticToString; +>staticToString : Symbol(staticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 4, 13)) +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) +} + +declare class StaticToNumber { +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) + + static toNumber(): void; +>toNumber : Symbol(StaticToNumber.toNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 8, 30)) +} +function bar(staticToNumber: StaticToNumber) { +>bar : Symbol(bar, Decl(instanceofOperatorWithInvalidStaticToString.ts, 10, 1)) +>staticToNumber : Symbol(staticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 11, 13)) +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) + + return staticToNumber instanceof StaticToNumber; +>staticToNumber : Symbol(staticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 11, 13)) +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) +} + +declare class NormalToString { +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) + + toString(): void; +>toString : Symbol(NormalToString.toString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 15, 30)) +} +function baz(normal: NormalToString) { +>baz : Symbol(baz, Decl(instanceofOperatorWithInvalidStaticToString.ts, 17, 1)) +>normal : Symbol(normal, Decl(instanceofOperatorWithInvalidStaticToString.ts, 18, 13)) +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) + + return normal instanceof NormalToString; +>normal : Symbol(normal, Decl(instanceofOperatorWithInvalidStaticToString.ts, 18, 13)) +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) +} + diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types new file mode 100644 index 00000000000..11efa0cffc3 --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts === +declare class StaticToString { +>StaticToString : StaticToString + + static toString(): void; +>toString : () => void +} + +function foo(staticToString: StaticToString) { +>foo : (staticToString: StaticToString) => boolean +>staticToString : StaticToString +>StaticToString : StaticToString + + return staticToString instanceof StaticToString; +>staticToString instanceof StaticToString : boolean +>staticToString : StaticToString +>StaticToString : typeof StaticToString +} + +declare class StaticToNumber { +>StaticToNumber : StaticToNumber + + static toNumber(): void; +>toNumber : () => void +} +function bar(staticToNumber: StaticToNumber) { +>bar : (staticToNumber: StaticToNumber) => boolean +>staticToNumber : StaticToNumber +>StaticToNumber : StaticToNumber + + return staticToNumber instanceof StaticToNumber; +>staticToNumber instanceof StaticToNumber : boolean +>staticToNumber : StaticToNumber +>StaticToNumber : typeof StaticToNumber +} + +declare class NormalToString { +>NormalToString : NormalToString + + toString(): void; +>toString : () => void +} +function baz(normal: NormalToString) { +>baz : (normal: NormalToString) => boolean +>normal : NormalToString +>NormalToString : NormalToString + + return normal instanceof NormalToString; +>normal instanceof NormalToString : boolean +>normal : NormalToString +>NormalToString : typeof NormalToString +} + diff --git a/tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts b/tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts new file mode 100644 index 00000000000..b99f8d71141 --- /dev/null +++ b/tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts @@ -0,0 +1,21 @@ +declare class StaticToString { + static toString(): void; +} + +function foo(staticToString: StaticToString) { + return staticToString instanceof StaticToString; +} + +declare class StaticToNumber { + static toNumber(): void; +} +function bar(staticToNumber: StaticToNumber) { + return staticToNumber instanceof StaticToNumber; +} + +declare class NormalToString { + toString(): void; +} +function baz(normal: NormalToString) { + return normal instanceof NormalToString; +} From 6b1cc8972d3e59f12cbc895e53ce90e76977faff Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 5 Dec 2016 14:13:32 -0800 Subject: [PATCH 022/175] Use native maps when they're available --- scripts/processDiagnosticMessages.ts | 10 +- src/compiler/binder.ts | 24 +- src/compiler/checker.ts | 397 +++++++++--------- src/compiler/commandLineParser.ts | 75 ++-- src/compiler/core.ts | 327 +++++++++++---- src/compiler/declarationEmitter.ts | 12 +- src/compiler/emitter.ts | 15 +- src/compiler/factory.ts | 28 +- src/compiler/parser.ts | 2 +- src/compiler/performance.ts | 20 +- src/compiler/program.ts | 44 +- src/compiler/scanner.ts | 17 +- src/compiler/sourcemap.ts | 2 +- src/compiler/sys.ts | 19 +- src/compiler/transformer.ts | 18 +- src/compiler/transformers/es2015.ts | 17 +- src/compiler/transformers/generators.ts | 24 +- src/compiler/transformers/jsx.ts | 2 +- src/compiler/transformers/module/module.ts | 48 +-- src/compiler/transformers/module/system.ts | 48 +-- src/compiler/transformers/ts.ts | 14 +- src/compiler/tsc.ts | 25 +- src/compiler/types.ts | 20 +- src/compiler/utilities.ts | 45 +- src/compiler/visitor.ts | 54 +-- src/harness/fourslash.ts | 28 +- src/harness/harness.ts | 15 +- src/harness/harnessLanguageService.ts | 4 +- src/harness/projectsRunner.ts | 21 +- .../unittests/cachingInServerLSHost.ts | 17 +- src/harness/unittests/moduleResolution.ts | 40 +- .../unittests/reuseProgramStructure.ts | 9 +- src/harness/unittests/session.ts | 16 +- .../unittests/tsserverProjectSystem.ts | 38 +- src/harness/unittests/typingsInstaller.ts | 2 +- src/server/builder.ts | 12 +- src/server/client.ts | 6 +- src/server/editorServices.ts | 70 +-- src/server/lsHost.ts | 7 +- src/server/project.ts | 52 +-- src/server/scriptInfo.ts | 2 +- src/server/session.ts | 6 +- src/server/typingsCache.ts | 25 +- .../typingsInstaller/typingsInstaller.ts | 30 +- src/server/utilities.ts | 21 +- src/services/classifier.ts | 2 +- src/services/codefixes/codeFixProvider.ts | 8 +- src/services/codefixes/importFixes.ts | 24 +- src/services/completions.ts | 38 +- src/services/documentHighlights.ts | 4 +- src/services/documentRegistry.ts | 8 +- src/services/findAllReferences.ts | 21 +- src/services/formatting/rules.ts | 2 +- src/services/goToDefinition.ts | 2 +- src/services/jsTyping.ts | 40 +- src/services/navigateTo.ts | 18 +- src/services/navigationBar.ts | 16 +- src/services/patternMatcher.ts | 6 +- src/services/services.ts | 11 +- src/services/signatureHelp.ts | 2 +- src/services/transpile.ts | 4 +- .../computedPropertyNames10_ES5.types | 4 +- .../computedPropertyNames10_ES6.types | 4 +- .../computedPropertyNames11_ES5.types | 4 +- .../computedPropertyNames11_ES6.types | 4 +- .../computedPropertyNames4_ES5.types | 4 +- .../computedPropertyNames4_ES6.types | 4 +- ...utedPropertyNamesContextualType6_ES5.types | 2 +- ...utedPropertyNamesContextualType6_ES6.types | 2 +- ...ntiationAssignmentWithIndexingOnLHS3.types | 16 +- ...rConstrainsPropertyDeclarations.errors.txt | 4 +- ...ConstrainsPropertyDeclarations2.errors.txt | 4 +- .../numericIndexerConstraint5.errors.txt | 4 +- .../objectLiteralIndexerErrors.errors.txt | 8 +- .../reference/objectLiteralIndexers.types | 10 +- ...ctTypeWithStringNamedNumericProperty.types | 30 +- ...rConstrainsPropertyDeclarations.errors.txt | 8 +- tests/cases/fourslash/fourslash.ts | 12 +- tests/cases/fourslash/localGetReferences.ts | 5 +- tslint.json | 3 +- 80 files changed, 1117 insertions(+), 949 deletions(-) diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index e5eaa46c8e5..db7a9e0f1f2 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -27,7 +27,7 @@ function main(): void { var inputFilePath = sys.args[0].replace(/\\/g, "/"); var inputStr = sys.readFile(inputFilePath); - + var diagnosticMessages: InputDiagnosticMessageTable = JSON.parse(inputStr); var names = Utilities.getObjectKeys(diagnosticMessages); @@ -44,7 +44,7 @@ function main(): void { function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosticMessageTable) { const originalMessageForCode: string[] = []; let numConflicts = 0; - + for (const currentMessage of messages) { const code = diagnosticTable[currentMessage].code; @@ -74,7 +74,7 @@ function buildUniqueNameMap(names: string[]): ts.Map { var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined); for (var i = 0; i < names.length; i++) { - nameMap[names[i]] = uniqueNames[i]; + nameMap.set(names[i], uniqueNames[i]); } return nameMap; @@ -91,7 +91,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: for (var i = 0; i < names.length; i++) { var name = names[i]; var diagnosticDetails = messageTable[name]; - var propName = convertPropertyName(nameMap[name]); + var propName = convertPropertyName(nameMap.get(name)); result += ' ' + propName + @@ -114,7 +114,7 @@ function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, for (var i = 0; i < names.length; i++) { var name = names[i]; var diagnosticDetails = messageTable[name]; - var propName = convertPropertyName(nameMap[name]); + var propName = convertPropertyName(nameMap.get(name)); result += '\r\n "' + createKey(propName, diagnosticDetails.code) + '"' + ' : "' + name.replace(/[\"]/g, '\\"') + '"'; if (i !== names.length - 1) { diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a6f5993f6c8..18a6d00e922 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -349,17 +349,17 @@ namespace ts { // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name)); + symbol = symbolTable.get(name) || set(symbolTable, name, createSymbol(SymbolFlags.None, name)); if (name && (includes & SymbolFlags.Classifiable)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name); + symbol = set(symbolTable, name, createSymbol(SymbolFlags.None, name)); } else { if (node.name) { @@ -1570,7 +1570,7 @@ namespace ts { const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); typeLiteralSymbol.members = createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node: ObjectLiteralExpression) { @@ -1601,9 +1601,9 @@ namespace ts { ? ElementKind.Property : ElementKind.Accessor; - const existingKind = seen[identifier.text]; + const existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } @@ -2208,7 +2208,7 @@ namespace ts { constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - const funcSymbol = container.locals[constructorFunction.text]; + const funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -2239,7 +2239,7 @@ namespace ts { bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { - classifiableNames[node.name.text] = node.name.text; + classifiableNames.set(node.name.text, node.name.text); } } @@ -2255,14 +2255,14 @@ namespace ts { // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + const symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { if (node.name) { node.name.parent = node; } - file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], - Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dc97d347e95..00a6ad2c366 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -371,7 +371,7 @@ namespace ts { } const builtinGlobals = createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); @@ -492,18 +492,19 @@ namespace ts { } function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { - for (const id in source) { - let targetSymbol = target[id]; + source.forEach((sourceSymbol, id) => { + let targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { if (!(targetSymbol.flags & SymbolFlags.Merged)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName: LiteralExpression): void { @@ -544,15 +545,16 @@ namespace ts { } function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) { - for (const id in source) { - if (target[id]) { + source.forEach((sourceSymbol, id) => { + const targetSymbol = target.get(id); + if (targetSymbol) { // Error on redeclarations - forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id: string, message: DiagnosticMessage) { return (declaration: Declaration) => diagnostics.add(createDiagnosticForNode(declaration, message, id)); @@ -580,7 +582,7 @@ namespace ts { function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { if (meaning) { - const symbol = symbols[name]; + const symbol = symbols.get(name); if (symbol) { Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { @@ -765,7 +767,7 @@ namespace ts { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports["default"]) { + if (result = moduleExports.get("default")) { const localSymbol = getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; @@ -784,9 +786,10 @@ namespace ts { // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, // which is not the desired behavior. - if (moduleExports[name] && - moduleExports[name].flags === SymbolFlags.Alias && - getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) { + const moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === SymbolFlags.Alias && + getDeclarationOfKind(moduleExport, SyntaxKind.ExportSpecifier)) { break; } } @@ -1114,11 +1117,16 @@ namespace ts { const moduleSymbol = resolveExternalModuleName(node, (node.parent).moduleSpecifier); if (moduleSymbol) { - const exportDefaultSymbol = isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + let exportDefaultSymbol: Symbol; + if (isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + const exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); @@ -1168,7 +1176,7 @@ namespace ts { function getExportOfModule(symbol: Symbol, name: string): Symbol { if (symbol.flags & SymbolFlags.Module) { - const exportedSymbol = getExportsOfSymbol(symbol)[name]; + const exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -1196,7 +1204,7 @@ namespace ts { let symbolFromVariable: Symbol; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { @@ -1475,7 +1483,7 @@ namespace ts { // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol: Symbol): Symbol { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' @@ -1491,7 +1499,7 @@ namespace ts { } function hasExportAssignmentSymbol(moduleSymbol: Symbol): boolean { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol: Symbol): Symbol[] { @@ -1501,7 +1509,7 @@ namespace ts { function tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined { const symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } @@ -1524,24 +1532,30 @@ namespace ts { * Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables */ function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map, exportNode?: ExportDeclaration) { - for (const id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + if (!source) return; + + source.forEach((sourceSymbol, id) => { + if (id === "default") return; + + const targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: getTextOfNode(exportNode.moduleSpecifier) - } as ExportCollisionTracker; + } as ExportCollisionTracker); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + const collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol: Symbol): SymbolTable { @@ -1561,7 +1575,7 @@ namespace ts { visitedSymbols.push(symbol); const symbols = cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - const exportStars = symbol.exports["__export"]; + const exportStars = symbol.exports.get("__export"); if (exportStars) { const nestedSymbols = createMap(); const lookupTable = createMap(); @@ -1575,21 +1589,20 @@ namespace ts { node as ExportDeclaration ); } - for (const id in lookupTable) { - const { exportsWithDuplicate } = lookupTable[id]; + lookupTable.forEach(({ exportsWithDuplicate }, id) => { // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } for (const node of exportsWithDuplicate) { diagnostics.add(createDiagnosticForNode( node, Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, - lookupTable[id].specifierText, + lookupTable.get(id).specifierText, id )); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -1684,15 +1697,14 @@ namespace ts { function getNamedMembers(members: SymbolTable): Symbol[] { let result: Symbol[]; - for (const id in members) { + members.forEach((symbol, id) => { if (!isReservedMemberName(id)) { if (!result) result = []; - const symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } @@ -1765,12 +1777,12 @@ namespace ts { } // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } // Check if symbol is any of the alias - return forEachProperty(symbols, symbolFromSymbolTable => { + return forEachInMap(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { @@ -1805,7 +1817,7 @@ namespace ts { let qualify = false; forEachSymbolTableInScope(enclosingDeclaration, symbolTable => { // If symbol of this name is not available in the symbol table we are ok - let symbolFromSymbolTable = symbolTable[symbol.name]; + let symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -3068,15 +3080,15 @@ namespace ts { const members = createMap(); const names = createMap(); for (const name of properties) { - names[getTextOfPropertyName(name)] = true; + names.set(getTextOfPropertyName(name), true); } for (const prop of getPropertiesOfType(source)) { - const inNamesToRemove = prop.name in names; + const inNamesToRemove = names.has(prop.name); const isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected); const isMethod = prop.flags & SymbolFlags.Method; const isSetOnlyAccessor = prop.flags & SymbolFlags.SetAccessor && !(prop.flags & SymbolFlags.GetAccessor); if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + members.set(prop.name, prop); } } const stringIndexInfo = getIndexInfoOfType(source, IndexKind.String); @@ -3338,7 +3350,7 @@ namespace ts { const symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); const result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -3939,7 +3951,7 @@ namespace ts { type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; (type).instantiations = createMap(); - (type).instantiations[getTypeListId(type.typeParameters)] = type; + (type).instantiations.set(getTypeListId(type.typeParameters), type); (type).target = type; (type).typeArguments = type.typeParameters; type.thisType = createType(TypeFlags.TypeParameter); @@ -3982,7 +3994,7 @@ namespace ts { // an instantiation of the type alias with the type parameters supplied as type arguments. links.typeParameters = typeParameters; links.instantiations = createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -4002,7 +4014,7 @@ namespace ts { return expr.kind === SyntaxKind.NumericLiteral || expr.kind === SyntaxKind.PrefixUnaryExpression && (expr).operator === SyntaxKind.MinusToken && (expr).operand.kind === SyntaxKind.NumericLiteral || - expr.kind === SyntaxKind.Identifier && !!symbol.exports[(expr).text]; + expr.kind === SyntaxKind.Identifier && !!symbol.exports.get((expr).text); } function enumHasLiteralMembers(symbol: Symbol) { @@ -4040,8 +4052,8 @@ namespace ts { for (const member of (declaration).members) { const memberSymbol = getSymbolOfNode(member); const value = getEnumMemberValue(member); - if (!memberTypes[value]) { - const memberType = memberTypes[value] = createEnumLiteralType(memberSymbol, enumType, "" + value); + if (!memberTypes.has(value)) { + const memberType = set(memberTypes, value, createEnumLiteralType(memberSymbol, enumType, "" + value)); memberTypeList.push(memberType); } } @@ -4051,7 +4063,7 @@ namespace ts { if (memberTypeList.length > 1) { enumType.flags |= TypeFlags.Union; (enumType).types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -4063,7 +4075,7 @@ namespace ts { if (!links.declaredType) { const enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); links.declaredType = enumType.flags & TypeFlags.Union ? - enumType.memberTypes[getEnumMemberValue(symbol.valueDeclaration)] : + enumType.memberTypes.get(getEnumMemberValue(symbol.valueDeclaration)) : enumType; } return links.declaredType; @@ -4195,7 +4207,7 @@ namespace ts { function createSymbolTable(symbols: Symbol[]): SymbolTable { const result = createMap(); for (const symbol of symbols) { - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -4205,15 +4217,15 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createMap(); for (const symbol of symbols) { - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) { for (const s of baseSymbols) { - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -4222,8 +4234,8 @@ namespace ts { if (!(type).declaredProperties) { const symbol = type.symbol; (type).declaredProperties = getNamedMembers(symbol.members); - (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); (type).declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); (type).declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); } @@ -4468,8 +4480,8 @@ namespace ts { } else if (symbol.flags & SymbolFlags.TypeLiteral) { const members = symbol.members; - const callSignatures = getSignaturesOfSymbol(members["__call"]); - const constructSignatures = getSignaturesOfSymbol(members["__new"]); + const callSignatures = getSignaturesOfSymbol(members.get("__call")); + const constructSignatures = getSignaturesOfSymbol(members.get("__new")); const stringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); const numberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -4483,7 +4495,7 @@ namespace ts { } if (symbol.flags & SymbolFlags.Class) { const classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } @@ -4541,7 +4553,7 @@ namespace ts { const prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | (isOptional ? SymbolFlags.Optional : 0), propName); prop.type = propType; prop.isReadonly = templateReadonly || homomorphicProp && isReadonlySymbol(homomorphicProp); - members[propName] = prop; + members.set(propName, prop); } else if (t.flags & TypeFlags.String) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -4623,7 +4635,7 @@ namespace ts { function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - const symbol = resolved.members[name]; + const symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -4644,13 +4656,12 @@ namespace ts { const props = type.resolvedProperties; if (props) { const result: Symbol[] = []; - for (const key in props) { - const prop = props[key]; + props.forEach(prop => { // We need to filter out partial properties in union types if (!(prop.flags & SymbolFlags.SyntheticProperty && (prop).isPartial)) { result.push(prop); } - } + }); return result; } return emptyArray; @@ -4770,11 +4781,11 @@ namespace ts { // and do not appear to be present in the union type. function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: string): Symbol { const properties = type.resolvedProperties || (type.resolvedProperties = createMap()); - let property = properties[name]; + let property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; @@ -4798,7 +4809,7 @@ namespace ts { type = getApparentType(type); if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - const symbol = resolved.members[name]; + const symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -4897,11 +4908,11 @@ namespace ts { function symbolsToArray(symbols: SymbolTable): Symbol[] { const result: Symbol[] = []; - for (const id in symbols) { + symbols.forEach((symbol, id) => { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } @@ -5175,7 +5186,7 @@ namespace ts { function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + return instantiations.get(id) || set(instantiations, id, createSignatureInstantiation(signature, typeArguments)); } function createSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { @@ -5209,7 +5220,7 @@ namespace ts { } function getIndexSymbol(symbol: Symbol): Symbol { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol: Symbol, kind: IndexKind): SignatureDeclaration { @@ -5323,9 +5334,9 @@ namespace ts { function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference { const id = getTypeListId(typeArguments); - let type = target.instantiations[id]; + let type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(ObjectFlags.Reference, target.symbol); + type = set(target.instantiations, id, createObjectType(ObjectFlags.Reference, target.symbol)); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -5372,7 +5383,7 @@ namespace ts { const links = getSymbolLinks(symbol); const typeParameters = links.typeParameters; const id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + return links.instantiations.get(id) || set(links.instantiations, id, instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); } // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include @@ -5613,7 +5624,7 @@ namespace ts { type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(TypeFlags.TypeParameter); @@ -5818,10 +5829,10 @@ namespace ts { return types[0]; } const id = getTypeListId(types); - let type = unionTypes[id]; + let type = unionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); - type = unionTypes[id] = createType(TypeFlags.Union | propagatedFlags); + type = set(unionTypes, id, createType(TypeFlags.Union | propagatedFlags)); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -5892,10 +5903,10 @@ namespace ts { /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); } const id = getTypeListId(typeSet); - let type = intersectionTypes[id]; + let type = intersectionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); - type = intersectionTypes[id] = createType(TypeFlags.Intersection | propagatedFlags); + type = set(intersectionTypes, id, createType(TypeFlags.Intersection | propagatedFlags)); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -6054,7 +6065,7 @@ namespace ts { } // Otherwise we defer the operation by creating an indexed access type. const id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + return indexedAccessTypes.get(id) || set(indexedAccessTypes, id, createIndexedAccessType(objectType, indexType)); } const apparentObjectType = getApparentType(objectType); if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Primitive)) { @@ -6099,7 +6110,7 @@ namespace ts { if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers const aliasSymbol = getAliasSymbolForTypeNode(node); - if (isEmpty(node.symbol.members) && !aliasSymbol) { + if (mapIsEmpty(node.symbol.members) && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -6164,19 +6175,19 @@ namespace ts { const isOwnProperty = !(rightProp.flags & SymbolFlags.Method) || isFromObjectLiteral; const isSetterWithoutGetter = rightProp.flags & SymbolFlags.SetAccessor && !(rightProp.flags & SymbolFlags.GetAccessor); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + members.set(rightProp.name, rightProp); } } for (const leftProp of getPropertiesOfType(left)) { if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name)) { continue; } - if (leftProp.name in members) { - const rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + const rightProp = members.get(leftProp.name); const rightType = getTypeOfSymbol(rightProp); if (maybeTypeOfKind(rightType, TypeFlags.Undefined) || rightProp.flags & SymbolFlags.Optional) { const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations); @@ -6187,11 +6198,11 @@ namespace ts { result.rightSpread = rightProp; result.declarations = declarations; result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); @@ -6221,7 +6232,7 @@ namespace ts { function getLiteralTypeForText(flags: TypeFlags, text: string) { const map = flags & TypeFlags.StringLiteral ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + return map.get(text) || set(map, text, createLiteralType(flags, text)); } function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { @@ -7006,13 +7017,14 @@ namespace ts { return true; } const id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + const relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & SymbolFlags.RegularEnum) || !(target.symbol.flags & SymbolFlags.RegularEnum) || (source.flags & TypeFlags.Union) !== (target.flags & TypeFlags.Union)) { - return enumRelation[id] = false; + return set(enumRelation, id, false); } const targetEnumType = getTypeOfSymbol(target.symbol); for (const property of getPropertiesOfType(getTypeOfSymbol(source.symbol))) { @@ -7023,11 +7035,11 @@ namespace ts { errorReporter(Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType)); } - return enumRelation[id] = false; + return set(enumRelation, id, false); } } } - return enumRelation[id] = true; + return set(enumRelation, id, true); } function isSimpleTypeRelatedTo(source: Type, target: Type, relation: Map, errorReporter?: ErrorReporter) { @@ -7070,7 +7082,7 @@ namespace ts { } if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - const related = relation[id]; + const related = relation.get(id); if (related !== undefined) { return related === RelationComparisonResult.Succeeded; } @@ -7527,12 +7539,12 @@ namespace ts { return Ternary.False; } const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - const related = relation[id]; + const related = relation.get(id); if (related !== undefined) { if (reportErrors && related === RelationComparisonResult.Failed) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. - relation[id] = RelationComparisonResult.FailedAndReported; + relation.set(id, RelationComparisonResult.FailedAndReported); } else { return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False; @@ -7541,7 +7553,7 @@ namespace ts { if (depth > 0) { for (let i = 0; i < depth; i++) { // If source and target are already being compared, consider them related with assumptions - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return Ternary.Maybe; } } @@ -7559,7 +7571,7 @@ namespace ts { sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = createMap(); - maybeStack[depth][id] = RelationComparisonResult.Succeeded; + maybeStack[depth].set(id, RelationComparisonResult.Succeeded); depth++; const saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; @@ -7592,12 +7604,12 @@ namespace ts { const maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up const destinationCache = (result === Ternary.True || depth === 0) ? relation : maybeStack[depth - 1]; - copyProperties(maybeCache, destinationCache); + copyMapEntries(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it // will also be false without assumptions) - relation[id] = reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed; + relation.set(id, reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed); } return result; } @@ -8266,7 +8278,7 @@ namespace ts { for (const property of getPropertiesOfObjectType(type)) { const original = getTypeOfSymbol(property); const updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createTransientSymbol(property, updated)); }; return members; } @@ -8508,7 +8520,7 @@ namespace ts { inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { const inferredIndexType = inferTargetType(indexInfo.type); @@ -8683,10 +8695,10 @@ namespace ts { return; } const key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -9067,7 +9079,7 @@ namespace ts { // check. This gives us a quicker out in the common case where an object type is not a function. const resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type: Type): TypeFacts { @@ -9687,8 +9699,9 @@ namespace ts { if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + const cached = cache.get(key); + if (cached) { + return cached; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. @@ -9722,8 +9735,9 @@ namespace ts { // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. - if (cache[key]) { - return cache[key]; + const cached = cache.get(key); + if (cached) { + return cached; } if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -9747,7 +9761,7 @@ namespace ts { if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } - return cache[key] = result; + return set(cache, key, result); } function isMatchingReferenceDiscriminant(expr: Expression) { @@ -9870,14 +9884,14 @@ namespace ts { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - const targetType = typeofTypesByName[literal.text]; + const targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } const facts = assumeTrue ? - typeofEQFacts[literal.text] || TypeFacts.TypeofEQHostObject : - typeofNEFacts[literal.text] || TypeFacts.TypeofNEHostObject; + typeofEQFacts.get(literal.text) || TypeFacts.TypeofEQHostObject : + typeofNEFacts.get(literal.text) || TypeFacts.TypeofNEHostObject; return getTypeWithFacts(type, facts); } @@ -11524,7 +11538,7 @@ namespace ts { } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } @@ -11533,12 +11547,12 @@ namespace ts { // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { for (const prop of getPropertiesOfType(contextualType)) { - if (!propertiesTable[prop.name]) { + if (!propertiesTable.get(prop.name)) { if (!(prop.flags & SymbolFlags.Optional)) { error(prop.valueDeclaration || (prop).bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } - propertiesTable[prop.name] = prop; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } @@ -11676,7 +11690,7 @@ namespace ts { checkTypeAssignableTo(exprType, correspondingPropType, node); } - nameTable[node.name.text] = true; + nameTable.set(node.name.text, true); return exprType; } @@ -11689,24 +11703,25 @@ namespace ts { for (const prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type - if (!nameTable[prop.name]) { + if (!nameTable.get(prop.name)) { const targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { const msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); } - nameTable[prop.name] = true; + nameTable.set(prop.name, true); } } return type; } function getJsxType(name: string) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + const jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + return set(jsxTypes, name, getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } /** @@ -12039,11 +12054,9 @@ namespace ts { // was spreaded in, though, assume that it provided all required properties if (targetAttributesType && !sawSpreadedAny) { const targetProperties = getPropertiesOfType(targetAttributesType); - for (let i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & SymbolFlags.Optional) && - !nameTable[targetProperties[i].name]) { - - error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + for (const targetProperty of targetProperties) { + if (!(targetProperty.flags & SymbolFlags.Optional) && !nameTable.get(targetProperty.name)) { + error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperty.name, typeToString(targetAttributesType)); } } } @@ -15462,17 +15475,17 @@ namespace ts { } function addName(names: Map, location: Node, name: string, meaning: Accessor) { - const prev = names[name]; + const prev = names.get(name); if (prev) { if (prev & meaning) { error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); } } } @@ -15492,12 +15505,12 @@ namespace ts { continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, Diagnostics.Duplicate_identifier_0, memberName); error(member.name, Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } @@ -16681,8 +16694,7 @@ namespace ts { function checkUnusedLocalsAndParameters(node: Node): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { - for (const key in node.locals) { - const local = node.locals[key]; + node.locals.forEach(local => { if (!local.isReferenced) { if (local.valueDeclaration && getRootDeclaration(local.valueDeclaration).kind === SyntaxKind.Parameter) { const parameter = getRootDeclaration(local.valueDeclaration); @@ -16697,7 +16709,7 @@ namespace ts { forEach(local.declarations, d => errorUnusedLocal(d.name || d, local.name)); } } - } + }); } } @@ -16763,8 +16775,7 @@ namespace ts { function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { - for (const key in node.locals) { - const local = node.locals[key]; + node.locals.forEach(local => { if (!local.isReferenced && !local.exportSymbol) { for (const declaration of local.declarations) { if (!isAmbientModule(declaration)) { @@ -16772,7 +16783,7 @@ namespace ts { } } } - } + }); } } @@ -17801,12 +17812,12 @@ namespace ts { else { const blockLocals = catchClause.block.locals; if (blockLocals) { - for (const caughtName in catchClause.locals) { - const blockLocal = blockLocals[caughtName]; + forEachKeyInMap(catchClause.locals, caughtName => { + const blockLocal = blockLocals.get(caughtName); if (blockLocal && (blockLocal.flags & SymbolFlags.BlockScopedVariable) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -18230,15 +18241,15 @@ namespace ts { } const seen = createMap<{ prop: Symbol; containingType: Type }>(); - forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; }); + forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.name, { prop: p, containingType: type }); }); let ok = true; for (const base of baseTypes) { const properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (const prop of properties) { - const existing = seen[prop.name]; + const existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { const isInheritedProperty = existing.containingType !== type; @@ -18980,19 +18991,14 @@ namespace ts { } function hasExportedMembers(moduleSymbol: Symbol) { - for (const id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return someKeyInMap(moduleSymbol.exports, id => id !== "export="); } function checkExternalModuleExports(node: SourceFile | ModuleDeclaration) { const moduleSymbol = getSymbolOfNode(node); const links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - const exportEqualsSymbol = moduleSymbol.exports["export="]; + const exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -19001,21 +19007,20 @@ namespace ts { } // Checks for export * conflicts const exports = getExportsOfModule(moduleSymbol); - for (const id in exports) { + exports && exports.forEach(({ declarations, flags }, id) => { if (id === "__export") { - continue; + return; } - const { declarations, flags } = exports[id]; // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) if (flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) { - continue; + return; } const exportedDeclarationsCount = countWhere(declarations, isNotOverload); if (flags & SymbolFlags.TypeAlias && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) - continue; + return; } if (exportedDeclarationsCount > 1) { for (const declaration of declarations) { @@ -19024,7 +19029,7 @@ namespace ts { } } } - } + }); links.exportsChecked = true; } @@ -19407,18 +19412,17 @@ namespace ts { // We will copy all symbol regardless of its reserved name because // symbolsToArray will check whether the key is a reserved name and // it will not copy symbol with reserved name to the array - if (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source: SymbolTable, meaning: SymbolFlags): void { if (meaning) { - for (const id in source) { - const symbol = source[id]; + source.forEach(symbol => { copySymbol(symbol, meaning); - } + }); } } } @@ -19829,8 +19833,8 @@ namespace ts { const propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, SignatureKind.Call).length || getSignaturesOfType(type, SignatureKind.Construct).length) { forEach(getPropertiesOfType(globalFunctionType), p => { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } @@ -19897,7 +19901,7 @@ namespace ts { // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & SymbolFlags.Value) - : forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : someInMap(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; @@ -20247,7 +20251,7 @@ namespace ts { } function hasGlobalName(name: string): boolean { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference: Identifier, startInDeclarationContainer?: boolean): Symbol { @@ -20304,14 +20308,13 @@ namespace ts { if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = createFileMap(); - for (const key in resolvedTypeReferenceDirectives) { - const resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach((resolvedDirective, key) => { if (!resolvedDirective) { - continue; + return; } const file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer, @@ -20455,11 +20458,11 @@ namespace ts { if (file.symbol && file.symbol.globalExports) { // Merge in UMD exports with first-in-wins semantics (see #9771) const source = file.symbol.globalExports; - for (const id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach((sourceSymbol, id) => { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } @@ -21211,17 +21214,17 @@ namespace ts { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + const existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - const existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { grammarErrorOnNode(name, Diagnostics.Duplicate_identifier_0, getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { return grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); @@ -21243,8 +21246,8 @@ namespace ts { const jsxAttr = (attr); const name = jsxAttr.name; - if (!seen[name.text]) { - seen[name.text] = true; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); @@ -21741,11 +21744,11 @@ namespace ts { function getAmbientModules(): Symbol[] { const result: Symbol[] = []; - for (const sym in globals) { + globals.forEach((global, sym) => { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 025218e62fd..7571804b5f4 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -531,9 +531,9 @@ namespace ts { const optionNameMap = createMap(); const shortOptionNames = createMap(); forEach(optionDeclarations, option => { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); @@ -543,7 +543,7 @@ namespace ts { /* @internal */ export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic { - const namesOfType = Object.keys(opt.type).map(key => `'${key}'`).join(", "); + const namesOfType = keysOfMap(opt.type).map(key => `'${key}'`).join(", "); return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType); } @@ -598,13 +598,13 @@ namespace ts { s = s.slice(s.charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase(); // Try to translate short option names to their full equivalents. - if (s in shortOptionNames) { - s = shortOptionNames[s]; + const short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - const opt = optionNameMap[s]; - + const opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -727,7 +727,7 @@ namespace ts { * @param fileNames array of filenames to be generated into tsconfig.json */ /* @internal */ - export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: Map } { + export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: MapLike } { const compilerOptions = extend(options, defaultInitCompilerOptions); const configurations: any = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -752,18 +752,17 @@ namespace ts { } } - function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: MapLike): string | undefined { + function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: Map): string | undefined { // There is a typeMap associated with this command-line option so use it to map value back to its name - for (const key in customTypeMap) { - if (customTypeMap[key] === value) { + return forEachInMap(customTypeMap, (mapValue, key) => { + if (mapValue === value) { return key; } - } - return undefined; + }); } - function serializeCompilerOptions(options: CompilerOptions): Map { - const result = createMap(); + function serializeCompilerOptions(options: CompilerOptions): MapLike { + const result = createMapLike(); const optionsNameMap = getOptionNameMap().optionNameMap; for (const name in options) { @@ -779,7 +778,7 @@ namespace ts { break; default: const value = options[name]; - let optionDefinition = optionsNameMap[name.toLowerCase()]; + let optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { @@ -1049,8 +1048,8 @@ namespace ts { const optionNameMap = arrayToMap(optionDeclarations, opt => opt.name); for (const id in jsonOptions) { - if (id in optionNameMap) { - const opt = optionNameMap[id]; + const opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -1086,8 +1085,9 @@ namespace ts { function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { const key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + const val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -1215,7 +1215,7 @@ namespace ts { // file map that marks whether it was a regular wildcard match (with a `*` or `?` token), // or a recursive directory. This information is used by filesystem watchers to monitor for // new entries in these paths. - const wildcardDirectories: Map = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + const wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); // Rather than requery this for each file and filespec, we query the supported extensions // once and store it on the expansion context. @@ -1226,7 +1226,7 @@ namespace ts { if (fileNames) { for (const fileName of fileNames) { const file = combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } @@ -1249,14 +1249,14 @@ namespace ts { removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); const key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - const literalFiles = reduceProperties(literalFileMap, addFileToOutput, []); - const wildcardFiles = reduceProperties(wildcardFileMap, addFileToOutput, []); + const literalFiles = valuesOfMap(literalFileMap); + const wildcardFiles = valuesOfMap(wildcardFileMap); wildcardFiles.sort(host.useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); return { fileNames: literalFiles.concat(wildcardFiles), @@ -1287,7 +1287,7 @@ namespace ts { /** * Gets directories in a set of include patterns that should be watched for changes. */ - function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): Map { + function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): MapLike { // We watch a directory recursively if it contains a wildcard anywhere in a directory segment // of the pattern: // @@ -1302,7 +1302,7 @@ namespace ts { // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude"); const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - const wildcardDirectories = createMap(); + const wildcardDirectories = createMapLike(); if (include !== undefined) { const recursiveKeys: string[] = []; for (const file of include) { @@ -1331,7 +1331,7 @@ namespace ts { delete wildcardDirectories[key]; } } - } + }; } return wildcardDirectories; @@ -1365,7 +1365,7 @@ namespace ts { for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) { const higherPriorityExtension = extensions[i]; const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -1387,21 +1387,10 @@ namespace ts { for (let i = nextExtensionPriority; i < extensions.length; i++) { const lowerPriorityExtension = extensions[i]; const lowerPriorityPath = keyMapper(changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - /** - * Adds a file to an array of files. - * - * @param output The output array. - * @param file The file path. - */ - function addFileToOutput(output: string[], file: string) { - output.push(file); - return output; - } - /** * Gets a case sensitive key. * diff --git a/src/compiler/core.ts b/src/compiler/core.ts index dec6b7cc485..affd225b3a7 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -23,13 +23,13 @@ namespace ts { True = -1 } - const createObject = Object.create; - // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - export function createMap(template?: MapLike): Map { - const map: Map = createObject(null); // tslint:disable-line:no-null-keyword + const createObject = Object.create; + /** Create a MapLike with good performance. Prefer this over a literal `{}`. */ + export function createMapLike(): MapLike { + const map = createObject(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is @@ -37,17 +37,141 @@ namespace ts { map["__"] = undefined; delete map["__"]; + return map; + } + + /** Create a new map. If a template object is provided, the map will copy entries from it. */ + export function createMap(template?: MapLike): Map { + const map: Map = new MapCtr(); + // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (const key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } + /** Create a map from [key, value] pairs. This avoids casting keys to strings. */ + export function createMapFromPairs(...pairs: [number, T][]): Map { + const map: Map = new MapCtr(); + + for (const [key, value] of pairs) { + map.set(key, value); + } + + return map; + } + + /** Methods on native maps but not on shim maps. Only used in this file. */ + interface ES6Map extends Map { + readonly size: number; + entries(): Iterator<[string, T]>; + keys(): Iterator; + } + + /** ES6 Iterator type. */ + interface Iterator { + next(): { value: T, done: false } | { value: never, done: true }; + } + + /** Shim maps support certain methods directly. For native maps we use a function. */ + interface ShimMap extends Map { + isEmpty(): boolean; + forEachInMap(callback: (value: T, key: string) => U | undefined): U | undefined; + forEachKey(callback: (key: string) => U | undefined): U | undefined; + some(predicate: (value: T, key: string) => boolean): boolean; + someKey(predicate: (key: string) => boolean): boolean; + } + + // The global Map object. This may not be available, so we must test for it. + declare const Map: { new(): Map } | undefined; + // Internet Explorer's Map doesn't support iteration, so don't use it. + // tslint:disable-next-line:no-in-operator + const usingNativeMaps = typeof Map !== "undefined" && "entries" in Map.prototype; + const MapCtr = usingNativeMaps ? Map : shimMap(); + + // Keep the class inside a function so it doesn't get compiled if it's not used. + function shimMap(): { new(): Map } { + return class implements ShimMap { + private data = createMapLike(); + + get(key: MapKey): T { + return this.data[key]; + } + + set(key: MapKey, value: T): this { + this.data[key] = value; + return this; + } + + has(key: MapKey): boolean { + // tslint:disable-next-line:no-in-operator + return key in this.data; + } + + delete(key: MapKey): boolean { + const had = this.has(key); + if (had) { + delete this.data[key]; + } + return had; + } + + clear(): void { + this.data = createMapLike(); + } + + forEach(action: (value: T, key: string) => void): void { + for (const key in this.data) { + action(this.data[key], key); + } + } + + isEmpty(): boolean { + return !this.someKey(() => true); + } + + forEachInMap(callback: (value: T, key: string) => U | undefined): U | undefined { + return this.forEachKey(key => callback(this.data[key], key)); + } + + forEachKey(callback: (key: string) => U | undefined): U | undefined { + for (const key in this.data) { + const result = callback(key); + if (result !== undefined) { + return result; + } + } + } + + some(predicate: (value: T, key: string) => boolean): boolean { + return this.someKey(key => predicate(this.data[key], key)); + } + + someKey(predicate: (key: string) => boolean): boolean { + for (const key in this.data) { + if (predicate(key)) { + return true; + } + } + return false; + } + } + } + + /** + * Unlike `map.set(key, value)`, this returns the value, making it useful as an expression. + * Prefer `map.set(key, value)` for statements. + */ + export function set(map: Map, key: MapKey, value: T): T { + map.set(key, value); + return value; + } + export function createFileMap(keyMapper?: (key: string) => string): FileMap { - let files = createMap(); + const files = createMap(); return { get, set, @@ -59,39 +183,34 @@ namespace ts { }; function forEachValueInMap(f: (key: Path, value: T) => void) { - for (const key in files) { - f(key, files[key]); - } + files.forEach((file, key) => { + f(key, file); + }); } function getKeys() { - const keys: Path[] = []; - for (const key in files) { - keys.push(key); - } - return keys; + return keysOfMap(files) as Path[]; } // path should already be well-formed so it does not need to be normalized function get(path: Path): T { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path: Path, value: T) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path: Path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path: Path) { - const key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path: Path): string { @@ -748,9 +867,6 @@ namespace ts { /** * Indicates whether a map-like contains an own property with the specified key. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * the 'in' operator. - * * @param map A map-like. * @param key A property key. */ @@ -761,9 +877,6 @@ namespace ts { /** * Gets the value of an owned property in a map-like. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * an indexer. - * * @param map A map-like. * @param key A property key. */ @@ -788,49 +901,86 @@ namespace ts { } /** - * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. - * - * @param map A map for which properties should be enumerated. - * @param callback A callback to invoke for each property. + * Array of every key in a map. + * May not actually return string[] if numbers were put into the map. */ - export function forEachProperty(map: Map, callback: (value: T, key: string) => U): U { - let result: U; - for (const key in map) { - if (result = callback(map[key], key)) break; - } - return result; + export function keysOfMap(map: Map): string[] { + const keys: string[] = []; + forEachKeyInMap(map, key => { + keys.push(key); + }); + return keys; + } + + /** Array of every value in a map. */ + export function valuesOfMap(map: Map): T[] { + const values: T[] = []; + map.forEach(value => { + values.push(value); + }); + return values; } /** - * Returns true if a Map has some matching property. - * - * @param map A map whose properties should be tested. - * @param predicate An optional callback used to test each property. + * Calls `callback` for each entry in the map, returning the first defined result. + * Use `map.forEach` instead for normal iteration. */ - export function someProperties(map: Map, predicate?: (value: T, key: string) => boolean) { - for (const key in map) { - if (!predicate || predicate(map[key], key)) return true; + export const forEachInMap: (map: Map, callback: (value: T, key: string) => U | undefined) => U | undefined = usingNativeMaps + ? (map: ES6Map, callback: (value: T, key: string) => U | undefined) => { + const iterator = map.entries(); + while (true) { + const { value: pair, done } = iterator.next(); + if (done) return undefined; + const [key, value] = pair; + const result = callback(value, key); + if (result !== undefined) return result; + } } - return false; - } + : (map: ShimMap, callback: (value: T, key: string) => U | undefined) => map.forEachInMap(callback); - /** - * Performs a shallow copy of the properties from a source Map to a target MapLike - * - * @param source A map from which properties should be copied. - * @param target A map to which properties should be copied. - */ - export function copyProperties(source: Map, target: MapLike): void { - for (const key in source) { - target[key] = source[key]; + /** `forEachInMap` for just keys. */ + export const forEachKeyInMap: (map: Map<{}>, callback: (key: string) => T | undefined) => T | undefined = usingNativeMaps + ? (map: ES6Map, callback: (key: string) => T | undefined) => { + const iterator = map.keys(); + while (true) { + const { value: key, done } = iterator.next(); + if (done) return undefined; + const result = callback(key); + if (result !== undefined) return result; + } } - } + : (map: ShimMap, callback: (key: string) => T | undefined) => map.forEachKey(callback); - export function appendProperty(map: Map, key: string | number, value: T): Map { - if (key === undefined || value === undefined) return map; - if (map === undefined) map = createMap(); - map[key] = value; - return map; + /** Whether `predicate` is true for some entry in the map. */ + export const someInMap: (map: Map, predicate: (value: T, key: string) => boolean) => boolean = usingNativeMaps + ? (map: ES6Map, predicate: (value: T, key: string) => boolean) => { + const iterator = map.entries(); + while (true) { + const { value: pair, done } = iterator.next(); + if (done) return false; + const [key, value] = pair; + if (predicate(value, key)) return true; + } + } + : (map: ShimMap, predicate: (value: T, key: string) => boolean) => map.some(predicate); + + /** Whether `predicate` is true for some key in the map. */ + export const someKeyInMap: (map: Map<{}>, predicate: (key: string) => boolean) => boolean = usingNativeMaps + ? (map: ES6Map<{}>, predicate: (key: string) => boolean) => { + const iterator = map.keys(); + while (true) { + const { value: key, done } = iterator.next(); + if (done) return false; + if (predicate(key)) return true; + } + } + : (map: ShimMap<{}>, predicate: (key: string) => boolean) => map.someKey(predicate); + + /** Copy entries from `source` to `target`. */ + export function copyMapEntries(source: Map, target: Map): void { + source.forEach((value, key) => { + target.set(key, value); + }); } export function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; @@ -845,24 +995,6 @@ namespace ts { return t; } - /** - * Reduce the properties of a map. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * reduceOwnProperties instead as it offers better runtime safety. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - export function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { - let result = initial; - for (const key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - /** * Performs a shallow equality comparison of the contents of two map-likes. * @@ -882,6 +1014,20 @@ namespace ts { return true; } + /** True if the maps have the same keys and values. */ + export function mapsAreEqual(left: Map, right: Map, valuesAreEqual?: (left: T, right: T) => boolean): boolean { + if (left === right) return true; + if (!left || !right) return false; + const someInLeftHasNoMatch = someInMap(left, (leftValue, leftKey) => { + if (!right.has(leftKey)) return true; + const rightValue = right.get(leftKey); + return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue); + }); + if (someInLeftHasNoMatch) return false; + const someInRightHasNoMatch = someKeyInMap(right, rightKey => !left.has(rightKey)); + return !someInRightHasNoMatch; + } + /** * Creates a map from the elements of an array. * @@ -897,23 +1043,18 @@ namespace ts { export function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue?: (value: T) => U): Map { const result = createMap(); for (const value of array) { - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } - export function isEmpty(map: Map) { - for (const id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } + export const mapIsEmpty: (map: Map<{}>) => boolean = usingNativeMaps + ? (map: ES6Map<{}>) => map.size === 0 + : (map: ShimMap<{}>) => map.isEmpty(); export function cloneMap(map: Map) { const clone = createMap(); - copyProperties(map, clone); + copyMapEntries(map, clone); return clone; } @@ -943,13 +1084,13 @@ namespace ts { * Creates the array if it does not already exist. */ export function multiMapAdd(map: Map, key: string | number, value: V): V[] { - const values = map[key]; + const values = map.get(key); if (values) { values.push(value); return values; } else { - return map[key] = [value]; + return set(map, key, [value]); } } @@ -959,11 +1100,11 @@ namespace ts { * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. */ export function multiMapRemove(map: Map, key: string, value: V): void { - const values = map[key]; + const values = map.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + map.delete(key); } } } @@ -1066,7 +1207,7 @@ namespace ts { return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]); } - export let localizedDiagnosticMessages: Map = undefined; + export let localizedDiagnosticMessages: MapLike = undefined; export function getLocaleSpecificMessage(message: DiagnosticMessage) { return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message; diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index cd98622e080..e010519d641 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -156,9 +156,9 @@ namespace ts { }); if (usedTypeDirectiveReferences) { - for (const directive in usedTypeDirectiveReferences) { + forEachKeyInMap(usedTypeDirectiveReferences, directive => { referencesOutput += `/// ${newLine}`; - } + }); } return { @@ -271,8 +271,8 @@ namespace ts { usedTypeDirectiveReferences = createMap(); } for (const directive of typeReferenceDirectives) { - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -581,14 +581,14 @@ namespace ts { // do not need to keep track of created temp names. function getExportDefaultTempVariableName(): string { const baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } let count = 0; while (true) { count++; const name = baseName + "_" + count; - if (!(name in currentIdentifiers)) { + if (!currentIdentifiers.has(name)) { return name; } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 90738d828be..191a39a5797 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2031,11 +2031,11 @@ namespace ts { // Skip the helper if it can be bundled but hasn't already been emitted and we // are emitting a bundled module. if (shouldBundle) { - if (bundledHelpers[helper.name]) { + if (bundledHelpers.get(helper.name)) { continue; } - bundledHelpers[helper.name] = true; + bundledHelpers.set(helper.name, true); } } else if (isBundle) { @@ -2487,15 +2487,16 @@ namespace ts { function isUniqueName(name: string): boolean { return !resolver.hasGlobalName(name) && - !hasProperty(currentFileIdentifiers, name) && - !hasProperty(generatedNameSet, name); + !currentFileIdentifiers.has(name) && + !generatedNameSet.has(name); } function isUniqueLocalName(name: string, container: Node): boolean { for (let node = container; isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && hasProperty(node.locals, name)) { + if (node.locals) { + const local = node.locals.get(name); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { + if (local && local.flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { return false; } } @@ -2544,7 +2545,7 @@ namespace ts { while (true) { const generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + return set(generatedNameSet, generatedName, generatedName); } i++; } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index ebcea221f9e..2ef73dea727 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2643,7 +2643,7 @@ namespace ts { function mergeTokenSourceMapRanges(sourceRanges: Map, destRanges: Map) { if (!destRanges) destRanges = createMap(); - copyProperties(sourceRanges, destRanges); + copyMapEntries(sourceRanges, destRanges); return destRanges; } @@ -2745,7 +2745,7 @@ namespace ts { export function getTokenSourceMapRange(node: Node, token: SyntaxKind) { const emitNode = node.emitNode; const tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges[token]; + return tokenSourceMapRanges && tokenSourceMapRanges.get(token); } /** @@ -2758,7 +2758,7 @@ namespace ts { export function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange) { const emitNode = getOrCreateEmitNode(node); const tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = createMap()); - tokenSourceMapRanges[token] = range; + tokenSourceMapRanges.set(token, range); return node; } @@ -2969,10 +2969,8 @@ namespace ts { * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName: LiteralExpression, sourceFile: SourceFile) { - if (sourceFile.renamedDependencies && hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + const rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && createLiteral(rename); } /** @@ -3332,7 +3330,7 @@ namespace ts { else { // export { x, y } for (const specifier of (node).exportClause.elements) { - if (!uniqueExports[specifier.name.text]) { + if (!uniqueExports.get(specifier.name.text)) { const name = specifier.propertyName || specifier.name; multiMapAdd(exportSpecifiers, name.text, specifier); @@ -3343,7 +3341,7 @@ namespace ts { multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = append(exportedNames, specifier.name); } } @@ -3377,9 +3375,9 @@ namespace ts { else { // export function x() { } const name = (node).name; - if (!uniqueExports[name.text]) { + if (!uniqueExports.get(name.text)) { multiMapAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports[name.text] = true; + uniqueExports.set(name.text, true); exportedNames = append(exportedNames, name); } } @@ -3398,9 +3396,9 @@ namespace ts { else { // export class x { } const name = (node).name; - if (!uniqueExports[name.text]) { + if (!uniqueExports.get(name.text)) { multiMapAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports[name.text] = true; + uniqueExports.set(name.text, true); exportedNames = append(exportedNames, name); } } @@ -3421,8 +3419,8 @@ namespace ts { } } else if (!isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = append(exportedNames, decl.name); } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4aefa160077..3da9093ee5a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1131,7 +1131,7 @@ namespace ts { function internIdentifier(text: string): string { text = escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + return identifiers.get(text) || set(identifiers, text, text); } // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index a48eb117e28..8c24b3b9f1b 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -27,8 +27,8 @@ namespace ts.performance { */ export function mark(markName: string) { if (enabled) { - marks[markName] = timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } @@ -44,9 +44,9 @@ namespace ts.performance { */ export function measure(measureName: string, startMarkName?: string, endMarkName?: string) { if (enabled) { - const end = endMarkName && marks[endMarkName] || timestamp(); - const start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + const end = endMarkName && marks.get(endMarkName) || timestamp(); + const start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } @@ -56,7 +56,7 @@ namespace ts.performance { * @param markName The name of the mark. */ export function getCount(markName: string) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } /** @@ -65,7 +65,7 @@ namespace ts.performance { * @param measureName The name of the measure whose durations should be accumulated. */ export function getDuration(measureName: string) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } /** @@ -74,9 +74,9 @@ namespace ts.performance { * @param cb The action to perform for each measure */ export function forEachMeasure(cb: (measureName: string, duration: number) => void) { - for (const key in measures) { - cb(key, measures[key]); - } + measures.forEach((measure, key) => { + cb(key, measure); + }); } /** Enables (and resets) performance measurements for the compiler. */ diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 73976d5d02e..3da9f57ca39 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -110,11 +110,11 @@ namespace ts { } function directoryExists(directoryPath: string): boolean { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -138,11 +138,11 @@ namespace ts { const hash = sys.createHash(data); const mtimeBefore = sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - const fingerprint = outputFingerprints[fileName]; - + if (mtimeBefore) { + const fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -153,11 +153,11 @@ namespace ts { const mtimeAfter = sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { @@ -277,9 +277,9 @@ namespace ts { const resolutions: T[] = []; const cache = createMap(); for (const name of names) { - const result = name in cache - ? cache[name] - : cache[name] = loader(name, containingFile); + const result = cache.has(name) + ? cache.get(name) + : set(cache, name, loader(name, containingFile)); resolutions.push(result); } return resolutions; @@ -454,7 +454,7 @@ namespace ts { classifiableNames = createMap(); for (const sourceFile of files) { - copyProperties(sourceFile.classifiableNames, classifiableNames); + copyMapEntries(sourceFile.classifiableNames, classifiableNames); } } @@ -729,7 +729,7 @@ namespace ts { } function isSourceFileFromExternalLibrary(file: SourceFile): boolean { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { @@ -1292,20 +1292,20 @@ namespace ts { // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file && sourceFilesFoundSearchingNodeModules[file.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file.path] = false; + if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file.path, false); if (!options.noResolve) { processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - modulesWithElidedImports[file.path] = false; + modulesWithElidedImports.set(file.path, false); processImportedModules(file); } // See if we need to reprocess the imports due to prior skipped imports - else if (file && modulesWithElidedImports[file.path]) { + else if (file && modulesWithElidedImports.get(file.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file.path] = false; + modulesWithElidedImports.set(file.path, false); processImportedModules(file); } } @@ -1326,7 +1326,7 @@ namespace ts { filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { @@ -1387,7 +1387,7 @@ namespace ts { refFile?: SourceFile, refPos?: number, refEnd?: number): void { // If we already found this library as a primary reference - nothing to do - const previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + const previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -1427,7 +1427,7 @@ namespace ts { } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } @@ -1480,7 +1480,7 @@ namespace ts { const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { const path = toPath(resolvedFileName, currentDirectory, getCanonicalFileName); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 82302e98e37..4f32b453ecd 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -275,9 +275,9 @@ namespace ts { function makeReverseMap(source: Map): string[] { const result: string[] = []; - for (const name in source) { - result[source[name]] = name; - } + source.forEach((value, name) => { + result[value] = name; + }); return result; } @@ -289,7 +289,7 @@ namespace ts { /* @internal */ export function stringToToken(s: string): SyntaxKind { - return textToToken[s]; + return textToToken.get(s); } /* @internal */ @@ -363,8 +363,6 @@ namespace ts { return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } - const hasOwnProperty = Object.prototype.hasOwnProperty; - export function isWhiteSpace(ch: number): boolean { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -1183,8 +1181,11 @@ namespace ts { const len = tokenValue.length; if (len >= 2 && len <= 11) { const ch = tokenValue.charCodeAt(0); - if (ch >= CharacterCodes.a && ch <= CharacterCodes.z && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= CharacterCodes.a && ch <= CharacterCodes.z) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = SyntaxKind.Identifier; diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 650b9b0ef02..a814a91c355 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -362,7 +362,7 @@ namespace ts { const emitNode = node && node.emitNode; const emitFlags = emitNode && emitNode.flags; - const range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; + const range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges.get(token); tokenPos = skipTrivia(currentSourceText, range ? range.pos : tokenPos); if ((emitFlags & EmitFlags.NoTokenLeadingSourceMaps) === 0 && tokenPos >= 0) { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a1e82a66595..c34527f8954 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -18,7 +18,7 @@ namespace ts { getFileSize?(path: string): number; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; /** - * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that + * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that * use native OS file watching */ watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; @@ -248,18 +248,18 @@ namespace ts { function reduceDirWatcherRefCountForFile(fileName: string) { const dirName = getDirectoryPath(fileName); - const watcher = dirWatchers[dirName]; + const watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath: string): void { - let watcher = dirWatchers[dirPath]; + let watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; @@ -270,7 +270,7 @@ namespace ts { (eventName: string, relativeFileName: string) => fileEventHandler(eventName, relativeFileName, dirPath) ); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } @@ -300,9 +300,12 @@ namespace ts { ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (const fileCallback of fileWatcherCallbacks[fileName]) { - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + const callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (const fileCallback of callbacks) { + fileCallback(fileName); + } } } } diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 10a718448e9..1440481d38e 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -13,14 +13,14 @@ /* @internal */ namespace ts { - const moduleTransformerMap = createMap({ - [ModuleKind.ES2015]: transformES2015Module, - [ModuleKind.System]: transformSystemModule, - [ModuleKind.AMD]: transformModule, - [ModuleKind.CommonJS]: transformModule, - [ModuleKind.UMD]: transformModule, - [ModuleKind.None]: transformModule, - }); + const moduleTransformerMap = createMapFromPairs( + [ModuleKind.ES2015, transformES2015Module], + [ModuleKind.System, transformSystemModule], + [ModuleKind.AMD, transformModule], + [ModuleKind.CommonJS, transformModule], + [ModuleKind.UMD, transformModule], + [ModuleKind.None, transformModule], + ); const enum SyntaxKindFeatureFlags { Substitution = 1 << 0, @@ -56,7 +56,7 @@ namespace ts { transformers.push(transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ModuleKind.None]); + transformers.push(moduleTransformerMap.get(moduleKind) || moduleTransformerMap.get(ModuleKind.None)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index c1398f75da6..13c44f2d7d5 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -561,7 +561,7 @@ namespace ts { // - break/continue is non-labeled and located in non-converted loop/switch statement const jump = node.kind === SyntaxKind.BreakStatement ? Jump.Break : Jump.Continue; const canUseBreakOrContinue = - (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { @@ -1929,7 +1929,7 @@ namespace ts { if (!convertedLoopState.labels) { convertedLoopState.labels = createMap(); } - convertedLoopState.labels[node.label.text] = node.label.text; + convertedLoopState.labels.set(node.label.text, node.label.text); } let result: VisitResult; @@ -1941,7 +1941,7 @@ namespace ts { } if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + convertedLoopState.labels.set(node.label.text, undefined); } return result; @@ -2548,13 +2548,13 @@ namespace ts { if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } @@ -2562,13 +2562,12 @@ namespace ts { if (!table) { return; } - for (const labelText in table) { - const labelMarker = table[labelText]; + table.forEach((labelMarker, labelText) => { const statements: Statement[] = []; // if there are no outer converted loop or outer label in question is located inside outer converted loop // then emit labeled break\continue // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { const label = createIdentifier(labelText); statements.push(isBreak ? createBreak(label) : createContinue(label)); } @@ -2577,7 +2576,7 @@ namespace ts { statements.push(createReturn(loopResultName)); } caseClauses.push(createCaseClause(createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl: VariableDeclaration | BindingElement, loopParameters: ParameterDeclaration[], loopOutParameters: LoopOutParameter[]) { diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index c383902d495..0b853649e81 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -217,13 +217,13 @@ namespace ts { Endfinally = 7, } - const instructionNames = createMap({ - [Instruction.Return]: "return", - [Instruction.Break]: "break", - [Instruction.Yield]: "yield", - [Instruction.YieldStar]: "yield*", - [Instruction.Endfinally]: "endfinally", - }); + const instructionNames = createMapFromPairs( + [Instruction.Return, "return"], + [Instruction.Break, "break"], + [Instruction.Yield, "yield"], + [Instruction.YieldStar, "yield*"], + [Instruction.Endfinally, "endfinally"], + ); export function transformGenerators(context: TransformationContext) { const { @@ -1921,12 +1921,12 @@ namespace ts { } function substituteExpressionIdentifier(node: Identifier) { - if (renamedCatchVariables && hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { const original = getOriginalNode(node); if (isIdentifier(original) && original.parent) { const declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - const name = getProperty(renamedCatchVariableDeclarations, String(getOriginalNodeId(declaration))); + const name = renamedCatchVariableDeclarations.get(getOriginalNodeId(declaration)); if (name) { const clone = getMutableClone(name); setSourceMapRange(clone, node); @@ -2096,8 +2096,8 @@ namespace ts { context.enableSubstitution(SyntaxKind.Identifier); } - renamedCatchVariables[text] = true; - renamedCatchVariableDeclarations[getOriginalNodeId(variable)] = name; + renamedCatchVariables.set(text, true); + renamedCatchVariableDeclarations.set(getOriginalNodeId(variable), name); const exception = peekBlock(); Debug.assert(exception.state < ExceptionBlockState.Catch); @@ -2401,7 +2401,7 @@ namespace ts { */ function createInstruction(instruction: Instruction): NumericLiteral { const literal = createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = instructionNames.get(instruction); return literal; } diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index ecb5dd053e0..0f7a0eb7fba 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -229,7 +229,7 @@ namespace ts { return String.fromCharCode(parseInt(hex, 16)); } else { - const ch = entities[word]; + const ch = entities.get(word); // If this is not a valid entity, then just use `match` (replace it with itself, i.e. don't replace) return ch ? String.fromCharCode(ch) : match; } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index c900b7d20e1..2e926406fb4 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -10,12 +10,12 @@ namespace ts { importAliasNames: ParameterDeclaration[]; } - const transformModuleDelegates = createMap<(node: SourceFile) => SourceFile>({ - [ModuleKind.None]: transformCommonJSModule, - [ModuleKind.CommonJS]: transformCommonJSModule, - [ModuleKind.AMD]: transformAMDModule, - [ModuleKind.UMD]: transformUMDModule, - }); + const transformModuleDelegates = createMapFromPairs<(node: SourceFile) => SourceFile>( + [ModuleKind.None, transformCommonJSModule], + [ModuleKind.CommonJS, transformCommonJSModule], + [ModuleKind.AMD, transformAMDModule], + [ModuleKind.UMD, transformUMDModule], + ); const { startLexicalEnvironment, @@ -60,10 +60,10 @@ namespace ts { } currentSourceFile = node; - currentModuleInfo = moduleInfoMap[getOriginalNodeId(node)] = collectExternalModuleInfo(node, resolver, compilerOptions); + currentModuleInfo = set(moduleInfoMap, getOriginalNodeId(node), collectExternalModuleInfo(node, resolver, compilerOptions)); // Perform the transformation. - const transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ModuleKind.None]; + const transformModule = transformModuleDelegates.get(moduleKind) || transformModuleDelegates.get(ModuleKind.None); const updated = transformModule(node); currentSourceFile = undefined; @@ -444,7 +444,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + deferredExports.set(id, appendExportsOfImportDeclaration(deferredExports.get(id), node)); } else { statements = appendExportsOfImportDeclaration(statements, node); @@ -523,7 +523,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + deferredExports.set(id, appendExportsOfImportEqualsDeclaration(deferredExports.get(id), node)); } else { statements = appendExportsOfImportEqualsDeclaration(statements, node); @@ -610,7 +610,7 @@ namespace ts { if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + deferredExports.set(id, appendExportStatement(deferredExports.get(id), createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true)); } else { statements = appendExportStatement(statements, createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); @@ -651,7 +651,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + deferredExports.set(id, appendExportsOfHoistedDeclaration(deferredExports.get(id), node)); } else { statements = appendExportsOfHoistedDeclaration(statements, node); @@ -690,7 +690,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + deferredExports.set(id, appendExportsOfHoistedDeclaration(deferredExports.get(id), node)); } else { statements = appendExportsOfHoistedDeclaration(statements, node); @@ -741,7 +741,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + deferredExports.set(id, appendExportsOfVariableStatement(deferredExports.get(id), node)); } else { statements = appendExportsOfVariableStatement(statements, node); @@ -794,7 +794,7 @@ namespace ts { // statement. if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === SyntaxKind.VariableStatement) { const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); + deferredExports.set(id, appendExportsOfVariableStatement(deferredExports.get(id), node.original)); } return node; @@ -820,9 +820,9 @@ namespace ts { // end of the transformed declaration. We use this marker to emit any deferred exports // of the declaration. const id = getOriginalNodeId(node); - const statements = deferredExports[id]; + const statements = deferredExports.get(id); if (statements) { - delete deferredExports[id]; + deferredExports.delete(id); return append(statements, node); } @@ -973,7 +973,7 @@ namespace ts { */ function appendExportsOfDeclaration(statements: Statement[] | undefined, decl: Declaration): Statement[] | undefined { const name = getDeclarationName(decl); - const exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); @@ -997,7 +997,7 @@ namespace ts { function appendExportStatement(statements: Statement[] | undefined, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean): Statement[] | undefined { if (exportName.text === "default") { const sourceFile = getOriginalNode(currentSourceFile, isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { + if (sourceFile && !sourceFile.symbol.exports.get("___esModule")) { if (languageVersion === ScriptTarget.ES3) { statements = append(statements, createStatement( @@ -1102,7 +1102,7 @@ namespace ts { function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { if (node.kind === SyntaxKind.SourceFile) { currentSourceFile = node; - currentModuleInfo = moduleInfoMap[getOriginalNodeId(currentSourceFile)]; + currentModuleInfo = moduleInfoMap.get(getOriginalNodeId(currentSourceFile)); noSubstitution = createMap(); previousOnEmitNode(emitContext, node, emitCallback); @@ -1128,7 +1128,7 @@ namespace ts { */ function onSubstituteNode(emitContext: EmitContext, node: Node) { node = previousOnSubstituteNode(emitContext, node); - if (node.id && noSubstitution[node.id]) { + if (node.id && noSubstitution.get(node.id)) { return node; } @@ -1254,7 +1254,7 @@ namespace ts { let expression: Expression = node; for (const exportName of exportedNames) { // Mark the node to prevent triggering this rule again. - noSubstitution[getNodeId(expression)] = true; + noSubstitution.set(getNodeId(expression), true); expression = createExportExpression(exportName, expression, /*location*/ node); } @@ -1296,7 +1296,7 @@ namespace ts { : node; for (const exportName of exportedNames) { // Mark the node to prevent triggering this rule again. - noSubstitution[getNodeId(expression)] = true; + noSubstitution.set(getNodeId(expression), true); expression = createExportExpression(exportName, expression); } @@ -1318,7 +1318,7 @@ namespace ts { || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { return currentModuleInfo - && currentModuleInfo.exportedBindings[getOriginalNodeId(valueDeclaration)]; + && currentModuleInfo.exportedBindings.get(getOriginalNodeId(valueDeclaration)); } } } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 91e29e09886..8d1e1749c0b 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -73,11 +73,11 @@ namespace ts { // see comment to 'substitutePostfixUnaryExpression' for more details // Collect information about the external module and dependency groups. - moduleInfo = moduleInfoMap[id] = collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfo = set(moduleInfoMap, id, collectExternalModuleInfo(node, resolver, compilerOptions)); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. - exportFunction = exportFunctionsMap[id] = createUniqueName("exports"); + exportFunction = set(exportFunctionsMap, id, createUniqueName("exports")); contextObject = createUniqueName("context"); // Add the body of the module. @@ -121,7 +121,7 @@ namespace ts { } if (noSubstitution) { - noSubstitutionMap[id] = noSubstitution; + noSubstitutionMap.set(id, noSubstitution); noSubstitution = undefined; } @@ -147,13 +147,13 @@ namespace ts { const externalImport = externalImports[i]; const externalModuleName = getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); const text = externalModuleName.text; - if (hasProperty(groupIndices, text)) { + const groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { // deduplicate/group entries in dependency list by the dependency name - const groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -305,7 +305,7 @@ namespace ts { // this set is used to filter names brought by star expors. // local names set should only be added if we have anything exported - if (!moduleInfo.exportedNames && isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && mapIsEmpty(moduleInfo.exportSpecifiers)) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. let hasExportDeclarationWithExportClause = false; @@ -608,7 +608,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + deferredExports.set(id, appendExportsOfImportDeclaration(deferredExports.get(id), node)); } else { statements = appendExportsOfImportDeclaration(statements, node); @@ -631,7 +631,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + deferredExports.set(id, appendExportsOfImportEqualsDeclaration(deferredExports.get(id), node)); } else { statements = appendExportsOfImportEqualsDeclaration(statements, node); @@ -656,7 +656,7 @@ namespace ts { if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], createIdentifier("default"), expression, /*allowComments*/ true); + deferredExports.set(id, appendExportStatement(deferredExports.get(id), createIdentifier("default"), expression, /*allowComments*/ true)); } else { return createExportStatement(createIdentifier("default"), expression, /*allowComments*/ true); @@ -688,7 +688,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + deferredExports.set(id, appendExportsOfHoistedDeclaration(deferredExports.get(id), node)); } else { hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node); @@ -730,7 +730,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + deferredExports.set(id, appendExportsOfHoistedDeclaration(deferredExports.get(id), node)); } else { statements = appendExportsOfHoistedDeclaration(statements, node); @@ -770,7 +770,7 @@ namespace ts { if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration); + deferredExports.set(id, appendExportsOfVariableStatement(deferredExports.get(id), node, isExportedDeclaration)); } else { statements = appendExportsOfVariableStatement(statements, node, /*exportSelf*/ false); @@ -883,7 +883,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === SyntaxKind.VariableStatement) { const id = getOriginalNodeId(node); const isExportedDeclaration = hasModifier(node.original, ModifierFlags.Export); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); + deferredExports.set(id, appendExportsOfVariableStatement(deferredExports.get(id), node.original, isExportedDeclaration)); } return node; @@ -909,9 +909,9 @@ namespace ts { // end of the transformed declaration. We use this marker to emit any deferred exports // of the declaration. const id = getOriginalNodeId(node); - const statements = deferredExports[id]; + const statements = deferredExports.get(id); if (statements) { - delete deferredExports[id]; + deferredExports.delete(id); return append(statements, node); } @@ -1080,7 +1080,7 @@ namespace ts { } const name = getDeclarationName(decl); - const exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + const exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { if (exportSpecifier.name.text !== excludeName) { @@ -1554,12 +1554,12 @@ namespace ts { if (node.kind === SyntaxKind.SourceFile) { const id = getOriginalNodeId(node); currentSourceFile = node; - moduleInfo = moduleInfoMap[id]; - exportFunction = exportFunctionsMap[id]; - noSubstitution = noSubstitutionMap[id]; + moduleInfo = moduleInfoMap.get(id); + exportFunction = exportFunctionsMap.get(id); + noSubstitution = noSubstitutionMap.get(id); if (noSubstitution) { - delete noSubstitutionMap[id]; + noSubstitutionMap.delete(id); } previousOnEmitNode(emitContext, node, emitCallback); @@ -1756,7 +1756,7 @@ namespace ts { exportedNames = append(exportedNames, getDeclarationName(valueDeclaration)); } - exportedNames = addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[getOriginalNodeId(valueDeclaration)]); + exportedNames = addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings.get(getOriginalNodeId(valueDeclaration))); } } @@ -1770,7 +1770,7 @@ namespace ts { */ function preventSubstitution(node: T): T { if (noSubstitution === undefined) noSubstitution = createMap(); - noSubstitution[getNodeId(node)] = true; + noSubstitution.set(getNodeId(node), true); return node; } @@ -1780,7 +1780,7 @@ namespace ts { * @param node The node to test. */ function isSubstitutionPrevented(node: Node) { - return noSubstitution && node.id && noSubstitution[node.id]; + return noSubstitution && node.id && noSubstitution.get(node.id); } } } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 77af854269e..4b0f981f27c 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -752,7 +752,7 @@ namespace ts { if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ClassWithConstructorReference) { // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); - classAliases[getOriginalNodeId(node)] = getSynthesizedClone(temp); + classAliases.set(getOriginalNodeId(node), getSynthesizedClone(temp)); } // To preserve the behavior of the old emitter, we explicitly indent @@ -1420,7 +1420,7 @@ namespace ts { return undefined; } - const classAlias = classAliases && classAliases[getOriginalNodeId(node)]; + const classAlias = classAliases && classAliases.get(getOriginalNodeId(node)); const localName = getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); const decorate = createDecorateHelper(context, decoratorExpressions, localName); const expression = createAssignment(localName, classAlias ? createAssignment(classAlias, decorate) : decorate); @@ -2530,8 +2530,8 @@ namespace ts { currentScopeFirstDeclarationsOfName = createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } @@ -2544,7 +2544,7 @@ namespace ts { if (currentScopeFirstDeclarationsOfName) { const name = node.symbol && node.symbol.name; if (name) { - return currentScopeFirstDeclarationsOfName[name] === node; + return currentScopeFirstDeclarationsOfName.get(name) === node; } } @@ -3085,7 +3085,7 @@ namespace ts { if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ClassWithConstructorReference) { enableSubstitutionForClassAliases(); const classAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default"); - classAliases[getOriginalNodeId(node)] = classAlias; + classAliases.set(getOriginalNodeId(node), classAlias); hoistVariableDeclaration(classAlias); return classAlias; } @@ -3230,7 +3230,7 @@ namespace ts { // constructor references in static property initializers. const declaration = resolver.getReferencedValueDeclaration(node); if (declaration) { - const classAlias = classAliases[declaration.id]; + const classAlias = classAliases.get(declaration.id); if (classAlias) { const clone = getSynthesizedClone(classAlias); setSourceMapRange(clone, node); diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a7304eebe4b..0e66ccb14b8 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -67,11 +67,11 @@ namespace ts { const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; - const categoryFormatMap = createMap({ - [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, - [DiagnosticCategory.Error]: redForegroundEscapeSequence, - [DiagnosticCategory.Message]: blueForegroundEscapeSequence, - }); + const categoryFormatMap = createMapFromPairs( + [DiagnosticCategory.Warning, yellowForegroundEscapeSequence], + [DiagnosticCategory.Error, redForegroundEscapeSequence], + [DiagnosticCategory.Message, blueForegroundEscapeSequence], + ); function formatAndReset(text: string, formatStyle: string) { return formatStyle + text + resetEscapeSequence; @@ -139,7 +139,7 @@ namespace ts { output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } - const categoryColor = categoryFormatMap[diagnostic.category]; + const categoryColor = categoryFormatMap.get(diagnostic.category); const category = DiagnosticCategory[diagnostic.category].toLowerCase(); output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; output += sys.newLine + sys.newLine; @@ -378,9 +378,8 @@ namespace ts { } function cachedFileExists(fileName: string): boolean { - return fileName in cachedExistingFiles - ? cachedExistingFiles[fileName] - : cachedExistingFiles[fileName] = hostFileExists(fileName); + const fileExists = cachedExistingFiles.get(fileName); + return fileExists !== undefined ? fileExists : set(cachedExistingFiles, fileName, hostFileExists(fileName)); } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { @@ -674,13 +673,9 @@ namespace ts { if (option.name === "lib") { description = getDiagnosticText(option.description); - const options: string[] = []; const element = (option).element; const typeMap = >element.type; - for (const key in typeMap) { - options.push(`'${key}'`); - } - optionsDescriptionMap[description] = options; + optionsDescriptionMap.set(description, keysOfMap(typeMap).map(key => `'${key}'`)); } else { description = getDiagnosticText(option.description); @@ -702,7 +697,7 @@ namespace ts { for (let i = 0; i < usageColumn.length; i++) { const usage = usageColumn[i]; const description = descriptionColumn[i]; - const kindsList = optionsDescriptionMap[description]; + const kindsList = optionsDescriptionMap.get(description); output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine); if (kindsList) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c1592d30eae..055049999ec 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,11 +1,25 @@ namespace ts { - + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ export interface MapLike { [index: string]: T; } - export interface Map extends MapLike { - __mapBrand: any; + /** It's allowed to get/set into a map with numbers. However, when iterating, you may get strings back due to the shim being an ordinary object (which only allows string keys). */ + export type MapKey = string | number; + + /** Minimal ES6 Map interface. */ + export interface Map { + get(key: MapKey): T; + has(key: MapKey): boolean; + set(key: MapKey, value: T): this; + delete(key: MapKey): boolean; + clear(): void; + /** `key` may *not* be a string if it was set with a number and we are not using the shim. */ + forEach(action: (value: T, key: string) => void): void; } // branded string type used to store absolute, normalized and canonicalized paths diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3dd7054a405..94b0fa20987 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -70,11 +70,11 @@ namespace ts { } export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void { @@ -82,7 +82,7 @@ namespace ts { sourceFile.resolvedModules = createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void { @@ -90,7 +90,7 @@ namespace ts { sourceFile.resolvedTypeReferenceDirectiveNames = createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } /* @internal */ @@ -112,7 +112,7 @@ namespace ts { } for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; - const oldResolution = oldResolutions && oldResolutions[names[i]]; + const oldResolution = oldResolutions && oldResolutions.get(names[i]); const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) @@ -2217,22 +2217,16 @@ namespace ts { } function reattachFileDiagnostics(newFile: SourceFile): void { - if (!hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - - for (const diagnostic of fileDiagnostics[newFile.fileName]) { - diagnostic.file = newFile; - } + forEach(fileDiagnostics.get(newFile.fileName), diagnostic => diagnostic.file = newFile); } function add(diagnostic: Diagnostic): void { let diagnostics: Diagnostic[]; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -2252,7 +2246,7 @@ namespace ts { function getDiagnostics(fileName?: string): Diagnostic[] { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } const allDiagnostics: Diagnostic[] = []; @@ -2262,9 +2256,9 @@ namespace ts { forEach(nonFileDiagnostics, pushDiagnostic); - for (const key in fileDiagnostics) { - forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(diagnostics => { + forEach(diagnostics, pushDiagnostic); + }); return sortAndDeduplicateDiagnostics(allDiagnostics); } @@ -2277,9 +2271,9 @@ namespace ts { diagnosticsModified = false; nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (const key in fileDiagnostics) { - fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach((diagnostics, key) => { + fileDiagnostics.set(key, sortAndDeduplicateDiagnostics(diagnostics)); + }); } } @@ -2316,7 +2310,7 @@ namespace ts { return s; function getReplacement(c: string) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } } @@ -3322,13 +3316,14 @@ namespace ts { export function formatSyntaxKind(kind: SyntaxKind): string { const syntaxKindEnum = (ts).SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + const cached = syntaxKindCache.get(kind); + if (cached !== undefined) { + return cached; } for (const name in syntaxKindEnum) { if (syntaxKindEnum[name] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name + ")"; + return set(syntaxKindCache, kind, kind.toString() + " (" + name + ")"); } } } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 43e01ca56bb..c9ea2af1a87 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -46,54 +46,54 @@ namespace ts { * supplant the existing `forEachChild` implementation if performance is not * significantly impacted. */ - const nodeEdgeTraversalMap = createMap({ - [SyntaxKind.QualifiedName]: [ + const nodeEdgeTraversalMap = createMapFromPairs( + [SyntaxKind.QualifiedName, [ { name: "left", test: isEntityName }, { name: "right", test: isIdentifier } - ], - [SyntaxKind.Decorator]: [ + ]], + [SyntaxKind.Decorator, [ { name: "expression", test: isLeftHandSideExpression } - ], - [SyntaxKind.TypeAssertionExpression]: [ + ]], + [SyntaxKind.TypeAssertionExpression, [ { name: "type", test: isTypeNode }, { name: "expression", test: isUnaryExpression } - ], - [SyntaxKind.AsExpression]: [ + ]], + [SyntaxKind.AsExpression, [ { name: "expression", test: isExpression }, { name: "type", test: isTypeNode } - ], - [SyntaxKind.NonNullExpression]: [ + ]], + [SyntaxKind.NonNullExpression, [ { name: "expression", test: isLeftHandSideExpression } - ], - [SyntaxKind.EnumDeclaration]: [ + ]], + [SyntaxKind.EnumDeclaration, [ { name: "decorators", test: isDecorator }, { name: "modifiers", test: isModifier }, { name: "name", test: isIdentifier }, { name: "members", test: isEnumMember } - ], - [SyntaxKind.ModuleDeclaration]: [ + ]], + [SyntaxKind.ModuleDeclaration, [ { name: "decorators", test: isDecorator }, { name: "modifiers", test: isModifier }, { name: "name", test: isModuleName }, { name: "body", test: isModuleBody } - ], - [SyntaxKind.ModuleBlock]: [ + ]], + [SyntaxKind.ModuleBlock, [ { name: "statements", test: isStatement } - ], - [SyntaxKind.ImportEqualsDeclaration]: [ + ]], + [SyntaxKind.ImportEqualsDeclaration, [ { name: "decorators", test: isDecorator }, { name: "modifiers", test: isModifier }, { name: "name", test: isIdentifier }, { name: "moduleReference", test: isModuleReference } - ], - [SyntaxKind.ExternalModuleReference]: [ + ]], + [SyntaxKind.ExternalModuleReference, [ { name: "expression", test: isExpression, optional: true } - ], - [SyntaxKind.EnumMember]: [ + ]], + [SyntaxKind.EnumMember, [ { name: "name", test: isPropertyName }, { name: "initializer", test: isExpression, optional: true, parenthesize: parenthesizeExpressionForList } - ] - }); + ]] + ); function reduceNode(node: Node, f: (memo: T, node: Node) => T, initial: T) { return node ? f(initial, node) : initial; @@ -530,7 +530,7 @@ namespace ts { break; default: - const edgeTraversalPath = nodeEdgeTraversalMap[kind]; + const edgeTraversalPath = nodeEdgeTraversalMap.get(kind); if (edgeTraversalPath) { for (const edge of edgeTraversalPath) { const value = (>node)[edge.name]; @@ -1188,10 +1188,10 @@ namespace ts { default: let updated: Node & MapLike; - const edgeTraversalPath = nodeEdgeTraversalMap[kind]; + const edgeTraversalPath = nodeEdgeTraversalMap.get(kind); if (edgeTraversalPath) { for (const edge of edgeTraversalPath) { - const value = >(>node)[edge.name]; + const value = >(>node)[edge.name]; if (value !== undefined) { const visited = isArray(value) ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 7c7a06db0b6..d4d6056f320 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -96,7 +96,7 @@ namespace FourSlash { }); export function escapeXmlAttributeValue(s: string) { - return s.replace(/[&<>"'\/]/g, ch => entityMap[ch]); + return s.replace(/[&<>"'\/]/g, ch => entityMap.get(ch)); } // Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions @@ -222,7 +222,7 @@ namespace FourSlash { } function tryAdd(path: string) { - const inputFile = inputFiles[path]; + const inputFile = inputFiles.get(path); if (inputFile && !Harness.isDefaultLibraryFile(path)) { languageServiceAdapterHost.addScript(path, inputFile, /*isRootFile*/ true); return true; @@ -256,7 +256,7 @@ namespace FourSlash { ts.forEach(testData.files, file => { // Create map between fileName and its content for easily looking up when resolveReference flag is specified - this.inputFiles[file.fileName] = file.content; + this.inputFiles.set(file.fileName, file.content); if (ts.getBaseFileName(file.fileName).toLowerCase() === "tsconfig.json") { const configJson = ts.parseConfigFileTextToJson(file.fileName, file.content); @@ -322,11 +322,11 @@ namespace FourSlash { } else { // resolveReference file-option is not specified then do not resolve any files and include all inputFiles - for (const fileName in this.inputFiles) { + this.inputFiles.forEach((file, fileName) => { if (!Harness.isDefaultLibraryFile(fileName)) { - this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName], /*isRootFile*/ true); + this.languageServiceAdapterHost.addScript(fileName, file, /*isRootFile*/ true); } - } + }); this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.getDefaultLibrarySourceFile().text, /*isRootFile*/ false); } @@ -659,11 +659,12 @@ namespace FourSlash { const completions = this.getCompletionListAtCaret(); const uniqueItems = ts.createMap(); for (const item of completions.entries) { - if (!(item.name in uniqueItems)) { - uniqueItems[item.name] = item.kind; + const uniqueItem = uniqueItems.get(item.name); + if (!uniqueItem) { + uniqueItems.set(item.name, item.kind); } else { - assert.equal(item.kind, uniqueItems[item.name], `Items should have the same kind, got ${item.kind} and ${uniqueItems[item.name]}`); + assert.equal(item.kind, uniqueItem, `Items should have the same kind, got ${item.kind} and ${uniqueItem}`); } } } @@ -831,7 +832,7 @@ namespace FourSlash { } public verifyRangesWithSameTextReferenceEachOther() { - ts.forEachProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); + this.rangesByText().forEach(ranges => this.verifyRangesReferenceEachOther(ranges)); } public verifyDisplayPartsOfReferencedSymbol(expected: ts.SymbolDisplayPart[]) { @@ -903,7 +904,8 @@ namespace FourSlash { } public verifyQuickInfos(namesAndTexts: { [name: string]: string | [string, string] }) { - ts.forEachProperty(ts.createMap(namesAndTexts), (text, name) => { + for (const name in namesAndTexts) if (ts.hasProperty(namesAndTexts, name)) { + const text = namesAndTexts[name]; if (text instanceof Array) { assert(text.length === 2); const [expectedText, expectedDocumentation] = text; @@ -912,7 +914,7 @@ namespace FourSlash { else { this.verifyQuickInfoAt(name, text); } - }); + } } public verifyQuickInfoString(expectedText: string, expectedDocumentation?: string) { @@ -2087,7 +2089,7 @@ namespace FourSlash { "<": ts.CharacterCodes.lessThan }); - const charCode = openBraceMap[openingBrace]; + const charCode = openBraceMap.get(openingBrace); if (!charCode) { this.raiseError(`Invalid openingBrace '${openingBrace}' specified.`); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 26a4a6f963d..265fe4c142c 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -918,10 +918,9 @@ namespace Harness { return undefined; } - if (!libFileNameSourceFileMap[fileName]) { - libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest); - } - return libFileNameSourceFileMap[fileName]; + const sourceFile = libFileNameSourceFileMap.get(fileName); + return sourceFile || ts.set(libFileNameSourceFileMap, fileName, + createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest)); } export function getDefaultLibFileName(options: ts.CompilerOptions): string { @@ -1103,10 +1102,10 @@ namespace Harness { optionsIndex = ts.createMap(); const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations); for (const option of optionDeclarations) { - optionsIndex[option.name.toLowerCase()] = option; + optionsIndex.set(option.name.toLowerCase(), option); } } - return optionsIndex[name.toLowerCase()]; + return optionsIndex.get(name.toLowerCase()); } export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void { @@ -1466,7 +1465,7 @@ namespace Harness { const fullResults = ts.createMap(); for (const sourceFile of allFiles) { - fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); + fullResults.set(sourceFile.unitName, fullWalker.getTypeAndSymbols(sourceFile.unitName)); } // Produce baselines. The first gives the types for all expressions. @@ -1519,7 +1518,7 @@ namespace Harness { allFiles.forEach(file => { const codeLines = file.content.split("\n"); - typeWriterResults[file.unitName].forEach(result => { + typeWriterResults.get(file.unitName).forEach(result => { if (isSymbolBaseline && !result.symbol) { return; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a49f8926729..2ddc38499d0 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -262,7 +262,7 @@ namespace Harness.LanguageService { this.getModuleResolutionsForFile = (fileName) => { const scriptInfo = this.getScriptInfo(fileName); const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true); - const imports = ts.createMap(); + const imports = ts.createMapLike(); for (const module of preprocessInfo.importedFiles) { const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); if (resolutionInfo.resolvedModule) { @@ -275,7 +275,7 @@ namespace Harness.LanguageService { const scriptInfo = this.getScriptInfo(fileName); if (scriptInfo) { const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false); - const resolutions = ts.createMap(); + const resolutions = ts.createMapLike(); const settings = this.nativeHost.getCompilationSettings(); for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) { const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost); diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index f7541dc9bfe..f1cc992c4a7 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -256,17 +256,20 @@ class ProjectRunner extends RunnerBase { // Set the values specified using json const optionNameMap = ts.arrayToMap(ts.optionDeclarations, option => option.name); for (const name in testCase) { - if (name !== "mapRoot" && name !== "sourceRoot" && name in optionNameMap) { - const option = optionNameMap[name]; - const optType = option.type; - let value = testCase[name]; - if (typeof optType !== "string") { - const key = value.toLowerCase(); - if (key in optType) { - value = optType[key]; + if (name !== "mapRoot" && name !== "sourceRoot") { + const option = optionNameMap.get(name); + if (option) { + const optType = option.type; + let value = testCase[name]; + if (typeof optType !== "string") { + const key = value.toLowerCase(); + const optTypeValue = optType.get(key); + if (optTypeValue) { + value = optTypeValue; + } } + compilerOptions[option.name] = value; } - compilerOptions[option.name] = value; } } diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 4286d3555d8..b6a90f53259 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -8,25 +8,28 @@ namespace ts { function createDefaultServerHost(fileMap: Map): server.ServerHost { const existingDirectories = createMap(); - for (const name in fileMap) { + forEachKeyInMap(fileMap, name => { let dir = getDirectoryPath(name); let previous: string; do { - existingDirectories[dir] = true; + existingDirectories.set(dir, true); previous = dir; dir = getDirectoryPath(dir); } while (dir !== previous); - } + }); return { args: [], newLine: "\r\n", useCaseSensitiveFileNames: false, write: noop, - readFile: path => path in fileMap ? fileMap[path].content : undefined, + readFile: path => { + const file = fileMap.get(path); + return file && file.content; + }, writeFile: notImplemented, resolvePath: notImplemented, - fileExists: path => path in fileMap, - directoryExists: path => existingDirectories[path] || false, + fileExists: path => fileMap.has(path), + directoryExists: path => existingDirectories.get(path) || false, createDirectory: noop, getExecutingFilePath: () => "", getCurrentDirectory: () => "", @@ -191,7 +194,7 @@ namespace ts { assert.isTrue(typeof diags[0].messageText === "string" && ((diags[0].messageText).indexOf("Cannot find module") === 0), "should be 'cannot find module' message"); // assert that import will success once file appear on disk - fileMap[imported.name] = imported; + fileMap.set(imported.name, imported); fileExistsCalledForBar = false; rootScriptInfo.editContent(0, root.content.length, `import {y} from "bar"`); diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 35313e15308..8e4ace38655 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -36,7 +36,7 @@ namespace ts { for (const f of files) { let name = getDirectoryPath(f.name); while (true) { - directories[name] = name; + directories.set(name, name); const baseName = getDirectoryPath(name); if (baseName === name) { break; @@ -46,20 +46,19 @@ namespace ts { } return { readFile, - directoryExists: path => { - return path in directories; - }, + directoryExists: path => directories.has(path), fileExists: path => { - assert.isTrue(getDirectoryPath(path) in directories, `'fileExists' '${path}' request in non-existing directory`); - return path in map; + assert.isTrue(directories.has(getDirectoryPath(path)), `'fileExists' '${path}' request in non-existing directory`); + return map.has(path); } }; } else { - return { readFile, fileExists: path => path in map, }; + return { readFile, fileExists: path => map.has(path) }; } function readFile(path: string): string { - return path in map ? map[path].content : undefined; + const file = map.get(path); + return file && file.content; } } @@ -300,7 +299,8 @@ namespace ts { const host: CompilerHost = { getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; + const file = files.get(path); + return file && createSourceFile(fileName, file, languageVersion); }, getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, @@ -311,7 +311,7 @@ namespace ts { useCaseSensitiveFileNames: () => false, fileExists: fileName => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return path in files; + return files.has(path); }, readFile: notImplemented }; @@ -371,7 +371,11 @@ export = C; function test(files: Map, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); if (!useCaseSensitiveFileNames) { - files = reduceProperties(files, (files, file, fileName) => (files[getCanonicalFileName(fileName)] = file, files), createMap()); + const oldFiles = files; + files = createMap(); + oldFiles.forEach((file, fileName) => { + files.set(getCanonicalFileName(fileName), file); + }); } const host: CompilerHost = { @@ -380,7 +384,8 @@ export = C; return library; } const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; + const file = files.get(path); + return file && createSourceFile(fileName, file, languageVersion); }, getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, @@ -391,7 +396,7 @@ export = C; useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, fileExists: fileName => { const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return path in files; + return files.has(path); }, readFile: notImplemented }; @@ -1020,8 +1025,8 @@ import b = require("./moduleB"); const names = map(files, f => f.name); const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES2015)), f => f.fileName); const compilerHost: CompilerHost = { - fileExists : fileName => fileName in sourceFiles, - getSourceFile: fileName => sourceFiles[fileName], + fileExists : fileName => sourceFiles.has(fileName), + getSourceFile: fileName => sourceFiles.get(fileName), getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, getCurrentDirectory: () => "/", @@ -1029,7 +1034,10 @@ import b = require("./moduleB"); getCanonicalFileName: f => f.toLowerCase(), getNewLine: () => "\r\n", useCaseSensitiveFileNames: () => false, - readFile: fileName => fileName in sourceFiles ? sourceFiles[fileName].text : undefined + readFile: fileName => { + const file = sourceFiles.get(fileName); + return file && file.text; + } }; const program1 = createProgram(names, {}, compilerHost); const diagnostics1 = program1.getFileProcessingDiagnostics().getDiagnostics(); diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 6dbd74e71d2..54c05a9c383 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -122,7 +122,7 @@ namespace ts { trace: s => trace.push(s), getTrace: () => trace, getSourceFile(fileName): SourceFile { - return files[fileName]; + return files.get(fileName); }, getDefaultLibFileName(): string { return "lib.d.ts"; @@ -143,9 +143,10 @@ namespace ts { getNewLine(): string { return sys ? sys.newLine : newLine; }, - fileExists: fileName => fileName in files, + fileExists: fileName => files.has(fileName), readFile: fileName => { - return fileName in files ? files[fileName].text : undefined; + const file = files.get(fileName); + return file && file.text; }, }; } @@ -188,7 +189,7 @@ namespace ts { } else { assert.isTrue(cache !== undefined, `expected ${caption} to be set`); - assert.isTrue(equalOwnProperties(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); + assert.isTrue(mapsAreEqual(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); } } diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 8800e84474b..da24fe1606b 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -422,9 +422,10 @@ namespace ts.server { handle(msg: protocol.Message): void { if (msg.type === "response") { const response = msg; - if (response.request_seq in this.callbacks) { - this.callbacks[response.request_seq](response); - delete this.callbacks[response.request_seq]; + const handler = this.callbacks.get(response.request_seq); + if (handler) { + handler(response); + this.callbacks.delete(response.request_seq); } } else if (msg.type === "event") { @@ -434,13 +435,14 @@ namespace ts.server { } emit(name: string, args: any): void { - if (name in this.eventHandlers) { - this.eventHandlers[name](args); + const handler = this.eventHandlers.get(name); + if (handler) { + handler(args); } } on(name: string, handler: (args: any) => void): void { - this.eventHandlers[name] = handler; + this.eventHandlers.set(name, handler); } connect(session: InProcSession): void { @@ -458,7 +460,7 @@ namespace ts.server { command, arguments: args }); - this.callbacks[this.seq] = callback; + this.callbacks.set(this.seq, callback); } }; diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 77ebee6fadd..bec3a700879 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -243,12 +243,18 @@ namespace ts.projectSystem { } export function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { - assert.equal(reduceProperties(map, count => count + 1, 0), expectedKeys.length, `${caption}: incorrect size of map`); + assert.equal(mapSize(map), expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { - assert.isTrue(name in map, `${caption} is expected to contain ${name}, actual keys: ${Object.keys(map)}`); + assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${keysOfMap(map)}`); } } + function mapSize(map: Map): number { + let size = 0; + map.forEach(() => { size++; }); + return size; + } + export function checkFileNames(caption: string, actualFileNames: string[], expectedFileNames: string[]) { assert.equal(actualFileNames.length, expectedFileNames.length, `${caption}: incorrect actual number of files, expected ${JSON.stringify(expectedFileNames)}, got ${actualFileNames}`); for (const f of expectedFileNames) { @@ -291,38 +297,30 @@ namespace ts.projectSystem { } export class Callbacks { - private map: { [n: number]: TimeOutCallback } = {}; + private map = createMap(); private nextId = 1; register(cb: (...args: any[]) => void, args: any[]) { const timeoutId = this.nextId; this.nextId++; - this.map[timeoutId] = cb.bind(undefined, ...args); + this.map.set(timeoutId, cb.bind(undefined, ...args)); return timeoutId; } unregister(id: any) { if (typeof id === "number") { - delete this.map[id]; + this.map.delete(id); } } count() { - let n = 0; - for (const _ in this.map) { - // TODO: GH#11734 - _; - n++; - } - return n; + return mapSize(this.map); } invoke() { - for (const id in this.map) { - if (hasProperty(this.map, id)) { - this.map[id](); - } - } - this.map = {}; + this.map.forEach(cb => { + cb(); + }); + this.map.clear(); } } @@ -439,7 +437,7 @@ namespace ts.projectSystem { triggerDirectoryWatcherCallback(directoryName: string, fileName: string): void { const path = this.toPath(directoryName); - const callbacks = this.watchedDirectories[path]; + const callbacks = this.watchedDirectories.get(path); if (callbacks) { for (const callback of callbacks) { callback.cb(fileName); @@ -449,7 +447,7 @@ namespace ts.projectSystem { triggerFileWatcherCallback(fileName: string, removed?: boolean): void { const path = this.toPath(fileName); - const callbacks = this.watchedFiles[path]; + const callbacks = this.watchedFiles.get(path); if (callbacks) { for (const callback of callbacks) { callback(path, removed); diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 62d2f7ac801..d99f12294af 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -14,7 +14,7 @@ namespace ts.projectSystem { function createTypesRegistry(...list: string[]): Map { const map = createMap(); for (const l of list) { - map[l] = undefined; + map.set(l, undefined); } return map; } diff --git a/src/server/builder.ts b/src/server/builder.ts index 5354e7ed508..44fb2224371 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -336,24 +336,24 @@ namespace ts.server { // Use slice to clone the array to avoid manipulating in place const queue = fileInfo.referencedBy.slice(0); const fileNameSet = createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; + fileNameSet.set(scriptInfo.fileName, scriptInfo); while (queue.length > 0) { const processingFileInfo = queue.pop(); if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { for (const potentialFileInfo of processingFileInfo.referencedBy) { - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { + if (!fileNameSet.has(potentialFileInfo.scriptInfo.fileName)) { queue.push(potentialFileInfo); } } } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; + fileNameSet.set(processingFileInfo.scriptInfo.fileName, processingFileInfo.scriptInfo); } const result: string[] = []; - for (const fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { + fileNameSet.forEach((scriptInfo, fileName) => { + if (shouldEmitFile(scriptInfo)) { result.push(fileName); } - } + }); return result; } } diff --git a/src/server/client.ts b/src/server/client.ts index 3b09a926754..13d16073d1c 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -31,10 +31,10 @@ namespace ts.server { } private getLineMap(fileName: string): number[] { - let lineMap = this.lineMaps[fileName]; + let lineMap = this.lineMaps.get(fileName); if (!lineMap) { const scriptSnapshot = this.host.getScriptSnapshot(fileName); - lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength())); + lineMap = set(this.lineMaps, fileName, ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength()))); } return lineMap; } @@ -140,7 +140,7 @@ namespace ts.server { changeFile(fileName: string, start: number, end: number, newText: string): void { // clear the line map after an edit - this.lineMaps[fileName] = undefined; + this.lineMaps.set(fileName, undefined); const lineOffset = this.positionToOneBasedLineOffset(fileName, start); const endLineOffset = this.positionToOneBasedLineOffset(fileName, end); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 9e53b3cd526..a358b0dab00 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -41,10 +41,10 @@ namespace ts.server { if (typeof option.type === "object") { const optionMap = >option.type; // verify that map contains only numbers - for (const id in optionMap) { - Debug.assert(typeof optionMap[id] === "number"); - } - map[option.name] = optionMap; + optionMap.forEach(value => { + Debug.assert(typeof value === "number"); + }); + map.set(option.name, optionMap); } } return map; @@ -59,20 +59,19 @@ namespace ts.server { export function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings { if (typeof protocolOptions.indentStyle === "string") { - protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); Debug.assert(protocolOptions.indentStyle !== undefined); } return protocolOptions; } export function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin { - for (const id in compilerOptionConverters) { + compilerOptionConverters.forEach((mappedValues, id) => { const propertyValue = protocolOptions[id]; if (typeof propertyValue === "string") { - const mappedValues = compilerOptionConverters[id]; - protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + protocolOptions[id] = mappedValues.get(propertyValue.toLowerCase()); } - } + }); return protocolOptions; } @@ -189,11 +188,12 @@ namespace ts.server { stopWatchingDirectory(directory: string) { // if the ref count for this directory watcher drops to 0, it's time to close it - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { + const refCount = this.directoryWatchersRefCount.get(directory) - 1; + this.directoryWatchersRefCount.set(directory, refCount); + if (refCount === 0) { this.projectService.logger.info(`Close directory watcher for: ${directory}`); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; + this.directoryWatchersForTsconfig.get(directory).close(); + this.directoryWatchersForTsconfig.delete(directory); } } @@ -201,13 +201,13 @@ namespace ts.server { let currentPath = getDirectoryPath(fileName); let parentPath = getDirectoryPath(currentPath); while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { + if (!this.directoryWatchersForTsconfig.has(currentPath)) { this.projectService.logger.info(`Add watcher for: ${currentPath}`); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; + this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); + this.directoryWatchersRefCount.set(currentPath, 1); } else { - this.directoryWatchersRefCount[currentPath] += 1; + this.directoryWatchersRefCount.set(currentPath, this.directoryWatchersRefCount.get(currentPath) + 1); } project.directoriesWatchedForTsconfig.push(currentPath); currentPath = parentPath; @@ -425,7 +425,7 @@ namespace ts.server { } else { if (info && (!info.isOpen)) { - // file has been changed which might affect the set of referenced files in projects that include + // file has been changed which might affect the set of referenced files in projects that include // this file and set of inferred projects info.reloadFromFile(); this.updateProjectGraphs(info.containingProjects); @@ -444,7 +444,7 @@ namespace ts.server { this.filenameToScriptInfo.remove(info.path); this.lastDeletedFile = info; - // capture list of projects since detachAllProjects will wipe out original list + // capture list of projects since detachAllProjects will wipe out original list const containingProjects = info.containingProjects.slice(); info.detachAllProjects(); @@ -600,7 +600,7 @@ namespace ts.server { const inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); if (!this.useSingleInferredProject) { // if useOneInferredProject is not set then try to fixup ownership of open files - // check 'defaultProject !== inferredProject' is necessary to handle cases + // check 'defaultProject !== inferredProject' is necessary to handle cases // when creation inferred project for some file has added other open files into this project (i.e. as referenced files) // we definitely don't want to delete the project that was just created for (const f of this.openFiles) { @@ -610,7 +610,7 @@ namespace ts.server { } const defaultProject = f.getDefaultProject(); if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - // open file used to be root in inferred project, + // open file used to be root in inferred project, // this inferred project is different from the one we've just created for current file // and new inferred project references this open file. // We should delete old inferred project and attach open file to the new one @@ -990,7 +990,7 @@ namespace ts.server { if (toAdd) { for (const f of toAdd) { if (f.isOpen && isRootFileInInferredProject(f)) { - // if file is already root in some inferred project + // if file is already root in some inferred project // - remove the file from that project and delete the project if necessary const inferredProject = f.containingProjects[0]; inferredProject.removeFile(f); @@ -1143,7 +1143,7 @@ namespace ts.server { this.logger.info(`Host information ${args.hostInfo}`); } if (args.formatOptions) { - mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + mergeMapLikes(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } } @@ -1265,7 +1265,7 @@ namespace ts.server { for (const file of changedFiles) { const scriptInfo = this.getScriptInfo(file.fileName); Debug.assert(!!scriptInfo); - // apply changes in reverse order + // apply changes in reverse order for (let i = file.changes.length - 1; i >= 0; i--) { const change = file.changes[i]; scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); @@ -1302,7 +1302,7 @@ namespace ts.server { closeExternalProject(uncheckedFileName: string, suppressRefresh = false): void { const fileName = toNormalizedPath(uncheckedFileName); - const configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + const configFiles = this.externalProjectToConfiguredProjectMap.get(fileName); if (configFiles) { let shouldRefreshInferredProjects = false; for (const configFile of configFiles) { @@ -1310,7 +1310,7 @@ namespace ts.server { shouldRefreshInferredProjects = true; } } - delete this.externalProjectToConfiguredProjectMap[fileName]; + this.externalProjectToConfiguredProjectMap.delete(fileName); if (shouldRefreshInferredProjects && !suppressRefresh) { this.refreshInferredProjects(); } @@ -1331,19 +1331,19 @@ namespace ts.server { // record project list before the update const projectsToClose = arrayToMap(this.externalProjects, p => p.getProjectName(), _ => true); for (const externalProjectName in this.externalProjectToConfiguredProjectMap) { - projectsToClose[externalProjectName] = true; + projectsToClose.set(externalProjectName, true); } for (const externalProject of projects) { this.openExternalProject(externalProject, /*suppressRefreshOfInferredProjects*/ true); // delete project that is present in input list - delete projectsToClose[externalProject.projectFileName]; + projectsToClose.delete(externalProject.projectFileName); } // close projects that were missing in the input list - for (const externalProjectName in projectsToClose) { + forEachKeyInMap(projectsToClose, externalProjectName => { this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true) - } + }); this.refreshInferredProjects(); } @@ -1386,7 +1386,7 @@ namespace ts.server { // close existing project and later we'll open a set of configured projects for these files this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true); } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { // this project used to include config files if (!tsConfigFiles) { // config files were removed from the project - close existing external project which in turn will close configured projects @@ -1394,7 +1394,7 @@ namespace ts.server { } else { // project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files - const oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); let iNew = 0; let iOld = 0; while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { @@ -1422,7 +1422,7 @@ namespace ts.server { } if (tsConfigFiles) { // store the list of tsconfig files that belong to the external project - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles); for (const tsconfigFile of tsConfigFiles) { let project = this.findConfiguredProjectByProjectName(tsconfigFile); if (!project) { @@ -1438,7 +1438,7 @@ namespace ts.server { } else { // no config files - remove the item from the collection - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); } if (!suppressRefreshOfInferredProjects) { diff --git a/src/server/lsHost.ts b/src/server/lsHost.ts index aa37008ff66..ffeeb57a0e8 100644 --- a/src/server/lsHost.ts +++ b/src/server/lsHost.ts @@ -75,15 +75,16 @@ namespace ts.server { for (const name of names) { // check if this is a duplicate entry in the list - let resolution = newResolutions[name]; + let resolution = newResolutions.get(name); if (!resolution) { - const existingResolution = currentResolutionsInFile && currentResolutionsInFile[name]; + const existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name); if (moduleResolutionIsValid(existingResolution)) { // ok, it is safe to use existing name resolution results resolution = existingResolution; } else { - newResolutions[name] = resolution = loader(name, containingFile, compilerOptions, this); + resolution = loader(name, containingFile, compilerOptions, this); + newResolutions.set(name, resolution); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); diff --git a/src/server/project.ts b/src/server/project.ts index 049f61269f8..14889dccd8a 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -495,9 +495,9 @@ namespace ts.server { } let unresolvedImports: string[]; if (file.resolvedModules) { - for (const name in file.resolvedModules) { + file.resolvedModules.forEach((resolvedModule, name) => { // pick unresolved non-relative names - if (!file.resolvedModules[name] && !isExternalModuleNameRelative(name)) { + if (!resolvedModule && !isExternalModuleNameRelative(name)) { // for non-scoped names extract part up-to the first slash // for scoped names - extract up to the second slash let trimmed = name.trim(); @@ -511,7 +511,7 @@ namespace ts.server { (unresolvedImports || (unresolvedImports = [])).push(trimmed); result.push(trimmed); } - } + }); } this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || emptyArray); } @@ -537,7 +537,7 @@ namespace ts.server { } // 1. no changes in structure, no changes in unresolved imports - do nothing - // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files + // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files // (can reuse cached imports for files that were not changed) // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files // (can reuse cached imports for files that were not changed) @@ -679,16 +679,16 @@ namespace ts.server { const added: string[] = []; const removed: string[] = []; - for (const id in currentFiles) { - if (!hasProperty(lastReportedFileNames, id)) { + forEachKeyInMap(currentFiles, id => { + if (!lastReportedFileNames.has(id)) { added.push(id); } - } - for (const id in lastReportedFileNames) { - if (!hasProperty(currentFiles, id)) { + }); + forEachKeyInMap(lastReportedFileNames, id => { + if (!currentFiles.has(id)) { removed.push(id); } - } + }); this.lastReportedFileNames = currentFiles; this.lastReportedVersion = this.projectStructureVersion; return { info, changes: { added, removed }, projectErrors: this.projectErrors }; @@ -722,7 +722,7 @@ namespace ts.server { if (symbol && symbol.declarations && symbol.declarations[0]) { const declarationSourceFile = symbol.declarations[0].getSourceFile(); if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; + referencedFiles.set(declarationSourceFile.path, true); } } } @@ -734,25 +734,24 @@ namespace ts.server { if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { for (const referencedFile of sourceFile.referencedFiles) { const referencedPath = toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; + referencedFiles.set(referencedPath, true); } } // Handle type reference directives if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (const typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - const resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + sourceFile.resolvedTypeReferenceDirectiveNames.forEach((resolvedTypeReferenceDirective) => { if (!resolvedTypeReferenceDirective) { - continue; + return; } const fileName = resolvedTypeReferenceDirective.resolvedFileName; const typeFilePath = toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; - } + referencedFiles.set(typeFilePath, true); + }) } - const allFileNames = map(Object.keys(referencedFiles), key => key); + const allFileNames = keysOfMap(referencedFiles) as Path[]; return filter(allFileNames, file => this.projectService.host.fileExists(file)); } @@ -888,18 +887,19 @@ namespace ts.server { return; } const configDirectoryPath = getDirectoryPath(this.getConfigFilePath()); - this.directoriesWatchedForWildcards = reduceProperties(this.wildcardDirectories, (watchers, flag, directory) => { + + this.directoriesWatchedForWildcards = createMap(); + this.wildcardDirectories.forEach((flag, directory) => { if (comparePaths(configDirectoryPath, directory, ".", !this.projectService.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; this.projectService.logger.info(`Add ${recursive ? "recursive " : ""}watcher for: ${directory}`); - watchers[directory] = this.projectService.host.watchDirectory( + this.directoriesWatchedForWildcards.set(directory, this.projectService.host.watchDirectory( directory, path => callback(this, path), recursive - ); + )); } - return watchers; - }, >{}); + }); } stopWatchingDirectory() { @@ -923,9 +923,9 @@ namespace ts.server { this.typeRootsWatchers = undefined; } - for (const id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); - } + this.directoriesWatchedForWildcards.forEach(watcher => { + watcher.close(); + }); this.directoriesWatchedForWildcards = undefined; this.stopWatchingDirectory(); diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 84649863a7b..fa9eac0e8e3 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -95,7 +95,7 @@ namespace ts.server { if (!this.formatCodeSettings) { this.formatCodeSettings = getDefaultFormatCodeSettings(this.host); } - mergeMaps(this.formatCodeSettings, formatSettings); + mergeMapLikes(this.formatCodeSettings, formatSettings); } } diff --git a/src/server/session.ts b/src/server/session.ts index 9abc5a447bf..0c200b33b84 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1607,14 +1607,14 @@ namespace ts.server { }); public addProtocolHandler(command: string, handler: (request: protocol.Request) => { response?: any, responseRequired: boolean }) { - if (command in this.handlers) { + if (this.handlers.has(command)) { throw new Error(`Protocol handler already exists for command "${command}"`); } - this.handlers[command] = handler; + this.handlers.set(command, handler); } public executeCommand(request: protocol.Request): { response?: any, responseRequired?: boolean } { - const handler = this.handlers[request.command]; + const handler = this.handlers.get(request.command); if (handler) { return handler(request); } diff --git a/src/server/typingsCache.ts b/src/server/typingsCache.ts index 8b03d59003c..9379ae82d0e 100644 --- a/src/server/typingsCache.ts +++ b/src/server/typingsCache.ts @@ -35,17 +35,18 @@ namespace ts.server { let unique = 0; for (const v of arr1) { - if (set[v] !== true) { - set[v] = true; + if (set.get(v) !== true) { + set.set(v, true); unique++; } } for (const v of arr2) { - if (!hasProperty(set, v)) { + const isSet = set.get(v); + if (isSet === undefined) { return false; } - if (set[v] === true) { - set[v] = false; + if (isSet === true) { + set.set(v, false); unique--; } } @@ -83,7 +84,7 @@ namespace ts.server { return emptyArray; } - const entry = this.perProjectCache[project.getProjectName()]; + const entry = this.perProjectCache.get(project.getProjectName()); const result: SortedReadonlyArray = entry ? entry.typings : emptyArray; if (forceRefresh || !entry || @@ -92,13 +93,13 @@ namespace ts.server { unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { // Note: entry is now poisoned since it does not really contain typings for a given combination of compiler options\typings options. // instead it acts as a placeholder to prevent issuing multiple requests - this.perProjectCache[project.getProjectName()] = { + this.perProjectCache.set(project.getProjectName(), { compilerOptions: project.getCompilerOptions(), typeAcquisition, typings: result, unresolvedImports, poisoned: true - }; + }); // something has been changed, issue a request to update typings this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } @@ -106,21 +107,21 @@ namespace ts.server { } updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]) { - this.perProjectCache[projectName] = { + this.perProjectCache.set(projectName, { compilerOptions, typeAcquisition, typings: toSortedReadonlyArray(newTypings), unresolvedImports, poisoned: false - }; + }); } deleteTypingsForProject(projectName: string) { - delete this.perProjectCache[projectName]; + this.perProjectCache.delete(projectName); } onProjectClosed(project: Project) { - delete this.perProjectCache[project.getProjectName()]; + this.perProjectCache.delete(project.getProjectName()); this.installer.onProjectClosed(project); } } diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 7a09c1f6c21..82184f86850 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -112,7 +112,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Closing file watchers for project '${projectName}'`); } - const watchers = this.projectWatchers[projectName]; + const watchers = this.projectWatchers.get(projectName); if (!watchers) { if (this.log.isEnabled()) { this.log.writeLine(`No watchers are registered for project '${projectName}'`); @@ -123,7 +123,7 @@ namespace ts.server.typingsInstaller { w.close(); } - delete this.projectWatchers[projectName]; + this.projectWatchers.delete(projectName); if (this.log.isEnabled()) { this.log.writeLine(`Closing file watchers for project '${projectName}' - done.`); @@ -177,7 +177,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Processing cache location '${cacheLocation}'`); } - if (this.knownCachesSet[cacheLocation]) { + if (this.knownCachesSet.get(cacheLocation)) { if (this.log.isEnabled()) { this.log.writeLine(`Cache location was already processed...`); } @@ -201,10 +201,10 @@ namespace ts.server.typingsInstaller { } const typingFile = typingToFileName(cacheLocation, packageName, this.installTypingHost, this.log); if (!typingFile) { - this.missingTypingsSet[packageName] = true; + this.missingTypingsSet.set(packageName, true); continue; } - const existingTypingFile = this.packageNameToTypingLocation[packageName]; + const existingTypingFile = this.packageNameToTypingLocation.get(packageName); if (existingTypingFile === typingFile) { continue; } @@ -216,14 +216,14 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Adding entry into typings cache: '${packageName}' => '${typingFile}'`); } - this.packageNameToTypingLocation[packageName] = typingFile; + this.packageNameToTypingLocation.set(packageName, typingFile); } } } if (this.log.isEnabled()) { this.log.writeLine(`Finished processing cache location '${cacheLocation}'`); } - this.knownCachesSet[cacheLocation] = true; + this.knownCachesSet.set(cacheLocation, true); } private filterTypings(typingsToInstall: string[]) { @@ -232,12 +232,12 @@ namespace ts.server.typingsInstaller { } const result: string[] = []; for (const typing of typingsToInstall) { - if (this.missingTypingsSet[typing] || this.packageNameToTypingLocation[typing]) { + if (this.missingTypingsSet.get(typing) || this.packageNameToTypingLocation.get(typing)) { continue; } const validationResult = validatePackageName(typing); if (validationResult === PackageNameValidationResult.Ok) { - if (typing in this.typesRegistry) { + if (this.typesRegistry.has(typing)) { result.push(typing); } else { @@ -248,7 +248,7 @@ namespace ts.server.typingsInstaller { } else { // add typing name to missing set so we won't process it again - this.missingTypingsSet[typing] = true; + this.missingTypingsSet.set(typing, true); if (this.log.isEnabled()) { switch (validationResult) { case PackageNameValidationResult.EmptyName: @@ -323,7 +323,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`install request failed, marking packages as missing to prevent repeated requests: ${JSON.stringify(filteredTypings)}`); } for (const typing of filteredTypings) { - this.missingTypingsSet[typing] = true; + this.missingTypingsSet.set(typing, true); } return; } @@ -336,11 +336,11 @@ namespace ts.server.typingsInstaller { for (const packageName of filteredTypings) { const typingFile = typingToFileName(cachePath, packageName, this.installTypingHost, this.log); if (!typingFile) { - this.missingTypingsSet[packageName] = true; + this.missingTypingsSet.set(packageName, true); continue; } - if (!this.packageNameToTypingLocation[packageName]) { - this.packageNameToTypingLocation[packageName] = typingFile; + if (!this.packageNameToTypingLocation.has(packageName)) { + this.packageNameToTypingLocation.set(packageName, typingFile); } installedTypingFiles.push(typingFile); } @@ -395,7 +395,7 @@ namespace ts.server.typingsInstaller { }, /*pollingInterval*/ 2000); watchers.push(w); } - this.projectWatchers[projectName] = watchers; + this.projectWatchers.set(projectName, watchers); } private createSetTypings(request: DiscoverTypings, typings: string[]): SetTypings { diff --git a/src/server/utilities.ts b/src/server/utilities.ts index fd370da7fa1..eb7801e5fd9 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -92,7 +92,7 @@ namespace ts.server { }; } - export function mergeMaps(target: MapLike, source: MapLike ): void { + export function mergeMapLikes(target: MapLike, source: MapLike ): void { for (const key in source) { if (hasProperty(source, key)) { target[key] = source[key]; @@ -142,20 +142,20 @@ namespace ts.server { export function createNormalizedPathMap(): NormalizedPathMap { /* tslint:disable:no-null-keyword */ - const map: Map = Object.create(null); + const map = createMap(); /* tslint:enable:no-null-keyword */ return { get(path) { - return map[path]; + return map.get(path); }, set(path, value) { - map[path] = value; + map.set(path, value); }, contains(path) { - return hasProperty(map, path); + return map.has(path); }, remove(path) { - delete map[path]; + map.delete(path); } }; } @@ -195,16 +195,17 @@ namespace ts.server { } public schedule(operationId: string, delay: number, cb: () => void) { - if (hasProperty(this.pendingTimeouts, operationId)) { + const pendingTimeout = this.pendingTimeouts.get(operationId); + if (pendingTimeout) { // another operation was already scheduled for this id - cancel it - this.host.clearTimeout(this.pendingTimeouts[operationId]); + this.host.clearTimeout(pendingTimeout); } // schedule new operation, pass arguments - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); } private static run(self: ThrottledOperations, operationId: string, cb: () => void) { - delete self.pendingTimeouts[operationId]; + self.pendingTimeouts.delete(operationId); cb(); } } diff --git a/src/services/classifier.ts b/src/services/classifier.ts index c22aec6a786..6c143ec2af0 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -557,7 +557,7 @@ namespace ts { // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run // in a third of the time it would normally take. - if (classifiableNames[identifier.text]) { + if (classifiableNames.get(identifier.text)) { const symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { const type = classifySymbol(symbol, getMeaningFromLocation(node)); diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index e4489fc2dca..c6373fc1909 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -20,21 +20,21 @@ namespace ts { export function registerCodeFix(action: CodeFix) { forEach(action.errorCodes, error => { - let fixes = codeFixes[error]; + let fixes = codeFixes.get(error); if (!fixes) { fixes = []; - codeFixes[error] = fixes; + codeFixes.set(error, fixes); } fixes.push(action); }); } export function getSupportedErrorCodes() { - return Object.keys(codeFixes); + return keysOfMap(codeFixes); } export function getFixes(context: CodeFixContext): CodeAction[] { - const fixes = codeFixes[context.errorCode]; + const fixes = codeFixes.get(context.errorCode); let allActions: CodeAction[] = []; forEach(fixes, f => { diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index bda310f2d33..0e7743e29fc 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -21,18 +21,19 @@ namespace ts.codefix { return; } - if (!this.symbolIdToActionMap[symbolId]) { - this.symbolIdToActionMap[symbolId] = [newAction]; + const actions = this.symbolIdToActionMap.get(symbolId); + if (!actions) { + this.symbolIdToActionMap.set(symbolId, [newAction]); return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } const updatedNewImports: ImportCodeAction[] = []; - for (const existingAction of this.symbolIdToActionMap[symbolId]) { + for (const existingAction of this.symbolIdToActionMap.get(symbolId)) { if (existingAction.kind === "CodeChange") { // only import actions should compare updatedNewImports.push(existingAction); @@ -62,7 +63,7 @@ namespace ts.codefix { } // if we reach here, it means the new one is better or equal to all of the existing ones. updatedNewImports.push(newAction); - this.symbolIdToActionMap[symbolId] = updatedNewImports; + this.symbolIdToActionMap.set(symbolId, updatedNewImports); } addActions(symbolId: number, newActions: ImportCodeAction[]) { @@ -73,9 +74,9 @@ namespace ts.codefix { getAllActions() { let result: ImportCodeAction[] = []; - for (const symbolId in this.symbolIdToActionMap) { - result = concatenate(result, this.symbolIdToActionMap[symbolId]); - } + this.symbolIdToActionMap.forEach(actions => { + result = concatenate(result, actions); + }); return result; } @@ -162,8 +163,9 @@ namespace ts.codefix { function getImportDeclarations(moduleSymbol: Symbol) { const moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + const cached = cachedImportDeclarations.get(moduleSymbolId); + if (cached) { + return cached; } const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; @@ -173,7 +175,7 @@ namespace ts.codefix { existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); } } - cachedImportDeclarations[moduleSymbolId] = existingDeclarations; + cachedImportDeclarations.set(moduleSymbolId, existingDeclarations); return existingDeclarations; function getImportDeclaration(moduleSpecifier: LiteralExpression) { diff --git a/src/services/completions.ts b/src/services/completions.ts index b710aa8cd78..f7efe1fec56 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -64,14 +64,14 @@ namespace ts.Completions { const entries: CompletionEntry[] = []; const nameTable = getNameTable(sourceFile); - for (const name in nameTable) { + nameTable.forEach((namePosition, name) => { // Skip identifiers produced only from the current location - if (nameTable[name] === position) { - continue; + if (namePosition === position) { + return; } - if (!uniqueNames[name]) { - uniqueNames[name] = name; + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { const entry = { @@ -83,7 +83,7 @@ namespace ts.Completions { entries.push(entry); } } - } + }); return entries; } @@ -122,9 +122,9 @@ namespace ts.Completions { const entry = createCompletionEntry(symbol, location, performCharacterChecks); if (entry) { const id = escapeIdentifier(entry.name); - if (!uniqueNames[id]) { + if (!uniqueNames.get(id)) { entries.push(entry); - uniqueNames[id] = id; + uniqueNames.set(id, id); } } } @@ -373,14 +373,14 @@ namespace ts.Completions { const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); } } - for (const foundFile in foundFiles) { + forEachKeyInMap(foundFiles, foundFile => { result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); - } + }); } // If possible, get folder completion as well @@ -1563,14 +1563,14 @@ namespace ts.Completions { } const name = element.propertyName || element.name; - existingImportsOrExports[name.text] = true; + existingImportsOrExports.set(name.text, true); } - if (!someProperties(existingImportsOrExports)) { + if (mapIsEmpty(existingImportsOrExports)) { return filter(exportsOfModule, e => e.name !== "default"); } - return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports[e.name]); + return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports.get(e.name)); } /** @@ -1616,10 +1616,10 @@ namespace ts.Completions { existingName = (m.name).text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return filter(contextualMemberSymbols, m => !existingMemberNames[m.name]); + return filter(contextualMemberSymbols, m => !existingMemberNames.get(m.name)); } /** @@ -1637,11 +1637,11 @@ namespace ts.Completions { } if (attr.kind === SyntaxKind.JsxAttribute) { - seenNames[(attr).name.text] = true; + seenNames.set((attr).name.text, true); } } - return filter(symbols, a => !seenNames[a.name]); + return filter(symbols, a => !seenNames.get(a.name)); } } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 0f18427e568..212e145ca60 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -44,11 +44,11 @@ namespace ts.DocumentHighlights { for (const referencedSymbol of referencedSymbols) { for (const referenceEntry of referencedSymbol.references) { const fileName = referenceEntry.fileName; - let documentHighlights = fileNameToDocumentHighlights[fileName]; + let documentHighlights = fileNameToDocumentHighlights.get(fileName); if (!documentHighlights) { documentHighlights = { fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; + fileNameToDocumentHighlights.set(fileName, documentHighlights); result.push(documentHighlights); } diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index d73e4d3b0a1..4291abf6c1f 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -113,16 +113,16 @@ namespace ts { } function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap { - let bucket = buckets[key]; + let bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = createFileMap(); + buckets.set(key, bucket = createFileMap()); } return bucket; } function reportStats() { - const bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === "_").map(name => { - const entries = buckets[name]; + const bucketInfoArray = keysOfMap(buckets).filter(name => name && name.charAt(0) === "_").map(name => { + const entries = buckets.get(name); const sourceFiles: { name: string; refCount: number; references: string[]; }[] = []; entries.forEachValue((key, entry) => { sourceFiles.push({ diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 313a3d2ea3e..9e53537b69b 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -96,7 +96,7 @@ namespace ts.FindAllReferences { const nameTable = getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { + if (nameTable.get(internedName) !== undefined) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } @@ -501,14 +501,14 @@ namespace ts.FindAllReferences { function findOwnConstructorCalls(classSymbol: Symbol): Node[] { const result: Node[] = []; - for (const decl of classSymbol.members["__constructor"].declarations) { + for (const decl of classSymbol.members.get("__constructor").declarations) { Debug.assert(decl.kind === SyntaxKind.Constructor); const ctrKeyword = decl.getChildAt(0); Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword); result.push(ctrKeyword); } - forEachProperty(classSymbol.exports, member => { + forEachInMap(classSymbol.exports, member => { const decl = member.valueDeclaration; if (decl && decl.kind === SyntaxKind.MethodDeclaration) { const body = (decl).body; @@ -528,7 +528,7 @@ namespace ts.FindAllReferences { /** Find references to `super` in the constructor of an extending class. */ function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] { const symbol = cls.symbol; - const ctr = symbol.members["__constructor"]; + const ctr = symbol.members.get("__constructor"); if (!ctr) { return []; } @@ -715,12 +715,13 @@ namespace ts.FindAllReferences { } const key = getSymbolId(symbol) + "," + getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; + const cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; } // Set the key so that we don't infinitely recurse - cachedResults[key] = false; + cachedResults.set(key, false); const inherits = forEach(symbol.getDeclarations(), declaration => { if (isClassLike(declaration)) { @@ -744,7 +745,7 @@ namespace ts.FindAllReferences { return false; }); - cachedResults[key] = inherits; + cachedResults.set(key, inherits); return inherits; } @@ -1078,7 +1079,7 @@ namespace ts.FindAllReferences { // the function will add any found symbol of the property-name, then its sub-routine will call // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (symbol.name in previousIterationSymbolsCache) { + if (previousIterationSymbolsCache.has(symbol.name)) { return; } @@ -1105,7 +1106,7 @@ namespace ts.FindAllReferences { } // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache[symbol.name] = symbol; + previousIterationSymbolsCache.set(symbol.name, symbol); getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); } } diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 2095f062bd1..215289159c2 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -4,7 +4,7 @@ namespace ts.formatting { export class Rules { public getRuleName(rule: Rule) { - const o: ts.Map = this; + const o: ts.MapLike = this; for (const name in o) { if (o[name] === rule) { return name; diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 4c005640d6a..d6ade7aed6b 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -14,7 +14,7 @@ namespace ts.GoToDefinition { // Type reference directives const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - const referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; + const referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); if (referenceFile && referenceFile.resolvedFileName) { return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 04ac60c4e74..e587a14b459 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -17,11 +17,11 @@ namespace ts.JsTyping { interface PackageJson { _requiredBy?: string[]; - dependencies?: Map; - devDependencies?: Map; + dependencies?: MapLike; + devDependencies?: MapLike; name?: string; - optionalDependencies?: Map; - peerDependencies?: Map; + optionalDependencies?: MapLike; + peerDependencies?: MapLike; typings?: string; }; @@ -107,34 +107,34 @@ namespace ts.JsTyping { // add typings for unresolved imports if (unresolvedImports) { for (const moduleId of unresolvedImports) { - const typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + const typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } // Add the cached typing locations for inferred typings that are already installed - for (const name in packageNameToTypingLocation) { - if (name in inferredTypings && !inferredTypings[name]) { - inferredTypings[name] = packageNameToTypingLocation[name]; + packageNameToTypingLocation.forEach((typingLocation, name) => { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); // Remove typings that the user has added to the exclude list for (const excludeTypingName of exclude) { - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } const newTypingNames: string[] = []; const cachedTypingPaths: string[] = []; - for (const typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach((inferred, typing) => { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths, newTypingNames, filesToWatch }; /** @@ -146,8 +146,8 @@ namespace ts.JsTyping { } for (const typing of typingNames) { - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -189,7 +189,7 @@ namespace ts.JsTyping { const cleanedTypingNames = map(inferredTypingNames, f => f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, "")); if (safeList !== EmptySafeList) { - mergeTypings(filter(cleanedTypingNames, f => f in safeList)); + mergeTypings(filter(cleanedTypingNames, f => safeList.has(f))); } const hasJsxFile = forEach(fileNames, f => ensureScriptKind(f, getScriptKindFromFileName(f)) === ScriptKind.JSX); @@ -236,7 +236,7 @@ namespace ts.JsTyping { } if (packageJson.typings) { const absolutePath = getNormalizedAbsolutePath(packageJson.typings, getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 82f4dd49f2b..40f22941268 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -7,23 +7,21 @@ namespace ts.NavigateTo { let rawItems: RawNavigateToItem[] = []; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - forEach(sourceFiles, sourceFile => { + for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + continue; } - const nameToDeclarations = sourceFile.getNamedDeclarations(); - for (const name in nameToDeclarations) { - const declarations = nameToDeclarations[name]; + forEachInMap(sourceFile.getNamedDeclarations(), (declarations, name) => { if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; // continue to next named declarations } for (const declaration of declarations) { @@ -32,13 +30,13 @@ namespace ts.NavigateTo { if (patternMatcher.patternContainsDots) { const containers = getContainers(declaration); if (!containers) { - return undefined; + return true; // Break out of named declarations and go to the next source file. } matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; // continue to next named declarations } } @@ -47,8 +45,8 @@ namespace ts.NavigateTo { rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration }); } } - } - }); + }); + } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = filter(rawItems, item => { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 1cbaa3d640f..7d95787939d 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -248,9 +248,9 @@ namespace ts.NavigationBar { return true; } - const itemsWithSameName = nameToItems[name]; + const itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } @@ -268,7 +268,7 @@ namespace ts.NavigationBar { if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } @@ -626,15 +626,15 @@ namespace ts.NavigationBar { /** * Matches all whitespace characters in a string. Eg: - * + * * "app. - * + * * onactivated" - * + * * matches because of the newline, whereas - * + * * "app.onactivated" - * + * * does not match. */ const whiteSpaceRegex = /\s+/g; diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index b4f67ca056d..b8941ef3147 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -188,11 +188,7 @@ namespace ts { } function getWordSpans(word: string): TextSpan[] { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); - } - - return stringToWordSpans[word]; + return stringToWordSpans.get(word) || set(stringToWordSpans, word, breakIntoWordSpans(word)); } function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch { diff --git a/src/services/services.ts b/src/services/services.ts index d28dd871105..77a5e916067 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -532,7 +532,7 @@ namespace ts { } function getDeclarations(name: string) { - return result[name] || (result[name] = []); + return result.get(name) || set(result, name, []); } function getDeclarationName(declaration: Declaration) { @@ -1956,9 +1956,11 @@ namespace ts { function walk(node: Node) { switch (node.kind) { - case SyntaxKind.Identifier: - nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; + case SyntaxKind.Identifier: { + const text = (node).text; + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); break; + } case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: // We want to store any numbers/strings if they were a name that could be @@ -1970,7 +1972,8 @@ namespace ts { isArgumentOfElementAccessExpression(node) || isLiteralComputedPropertyDeclarationName(node)) { - nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; + const text = (node).text; + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); } break; default: diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 44c2ede9fbb..aa799eb32c7 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -237,7 +237,7 @@ namespace ts.SignatureHelp { const typeChecker = program.getTypeChecker(); for (const sourceFile of program.getSourceFiles()) { const nameToDeclarations = sourceFile.getNamedDeclarations(); - const declarations = nameToDeclarations[name.text]; + const declarations = nameToDeclarations.get(name.text); if (declarations) { for (const declaration of declarations) { diff --git a/src/services/transpile.ts b/src/services/transpile.ts index da54faed1a2..d989a528497 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -126,7 +126,7 @@ namespace ts { function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, o => - typeof o.type === "object" && !forEachProperty(o.type, v => typeof v !== "number")); + typeof o.type === "object" && !forEachInMap(o.type, v => typeof v !== "number")); options = clone(options); @@ -142,7 +142,7 @@ namespace ts { options[opt.name] = parseCustomTypeOption(opt, value, diagnostics); } else { - if (!forEachProperty(opt.type, v => v === value)) { + if (!someInMap(opt.type, v => v === value)) { // Supplied value isn't a valid enum value. diagnostics.push(createCompilerDiagnosticForInvalidCustomType(opt)); } diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.types b/tests/baselines/reference/computedPropertyNames10_ES5.types index 650890fb10e..96130979298 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.types +++ b/tests/baselines/reference/computedPropertyNames10_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } ->{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } +>v : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } +>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } [s]() { }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames10_ES6.types b/tests/baselines/reference/computedPropertyNames10_ES6.types index 2ff86ed9712..5bbda2e8f19 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES6.types +++ b/tests/baselines/reference/computedPropertyNames10_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } ->{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } +>v : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } +>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } [s]() { }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.types b/tests/baselines/reference/computedPropertyNames11_ES5.types index 0787a889f40..88fbc690323 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.types +++ b/tests/baselines/reference/computedPropertyNames11_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } ->{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } +>v : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } +>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } get [s]() { return 0; }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES6.types b/tests/baselines/reference/computedPropertyNames11_ES6.types index 4783d07a2af..458d6d1de49 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES6.types +++ b/tests/baselines/reference/computedPropertyNames11_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } ->{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } +>v : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } +>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } get [s]() { return 0; }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.types b/tests/baselines/reference/computedPropertyNames4_ES5.types index 64ef5f6a611..6f875aaddac 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.types +++ b/tests/baselines/reference/computedPropertyNames4_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames4_ES6.types b/tests/baselines/reference/computedPropertyNames4_ES6.types index 0c608e21601..e9feac0a81f 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES6.types +++ b/tests/baselines/reference/computedPropertyNames4_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types index 91ad88c8ade..f144bb9d020 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; 0: () => void; p: ""; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; p: ""; 0: () => void; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types index 131e49dd173..6b8c8ae2e34 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; 0: () => void; p: ""; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; p: ""; 0: () => void; } p: "", >p : string diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types index 94a5f2173aa..32e5b33e411 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types @@ -1,8 +1,8 @@ === tests/cases/conformance/es7/exponentiationOperator/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts === var object = { ->object : { 0: number; _0: number; } ->{ _0: 2, get 0() { return this._0; }, set 0(x: number) { this._0 = x; },} : { 0: number; _0: number; } +>object : { _0: number; 0: number; } +>{ _0: 2, get 0() { return this._0; }, set 0(x: number) { this._0 = x; },} : { _0: number; 0: number; } _0: 2, >_0 : number @@ -30,31 +30,31 @@ var object = { object[0] **= object[0]; >object[0] **= object[0] : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 object[0] **= object[0] **= 2; >object[0] **= object[0] **= 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] **= 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >2 : 2 object[0] **= object[0] ** 2; >object[0] **= object[0] ** 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] ** 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >2 : 2 diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index ec0f330f1a3..f532bd23755 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(79,5): error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(79,5): error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ [x: number]: string; }'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -107,7 +107,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo var b: { [x: number]: string; } = { a: '', ~~~~~ -!!! error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. +!!! error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ [x: number]: string; }'. b: 1, c: () => { }, diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index e6d22ff0712..74cd032c40e 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(44,5): error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(44,5): error TS2322: Type '{ 1.0: A; 2.0: B; "2.5": B; 3.0: number; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. Object literal may only specify known properties, and '"4.0"' does not exist in type '{ [x: number]: A; }'. @@ -57,6 +57,6 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 3.0: 1, "4.0": '' ~~~~~~~~~ -!!! error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +!!! error TS2322: Type '{ 1.0: A; 2.0: B; "2.5": B; 3.0: number; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. !!! error TS2322: Object literal may only specify known properties, and '"4.0"' does not exist in type '{ [x: number]: A; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerConstraint5.errors.txt b/tests/baselines/reference/numericIndexerConstraint5.errors.txt index cb888de08c4..04b7e0dc337 100644 --- a/tests/baselines/reference/numericIndexerConstraint5.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'. +tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ name: string; 0: Date; }' is not assignable to type '{ [name: number]: string; }'. Property '0' is incompatible with index signature. Type 'Date' is not assignable to type 'string'. @@ -7,6 +7,6 @@ tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: var x = { name: "x", 0: new Date() }; var z: { [name: number]: string } = x; ~ -!!! error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'. +!!! error TS2322: Type '{ name: string; 0: Date; }' is not assignable to type '{ [name: number]: string; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'Date' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index 9d5ff7ea0a2..53abb5b7658 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ x: B; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Property '0' is incompatible with index signature. Type 'A' is not assignable to type 'B'. Property 'y' is missing in type 'A'. -tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ 0: A; x: any; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ x: any; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Property '0' is incompatible with index signature. Type 'A' is not assignable to type 'B'. @@ -22,12 +22,12 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ -!!! error TS2322: Type '{ 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ x: B; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'A' is not assignable to type 'B'. !!! error TS2322: Property 'y' is missing in type 'A'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A ~~ -!!! error TS2322: Type '{ 0: A; x: any; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ x: any; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index 9e3aa4bac49..ef242fd1fe3 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,23 +31,23 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { 0: B; x: A; } +>{ x: a, 0: b } : { x: A; 0: B; } >x : A >a : A >b : B o1 = { x: b, 0: c }; // both indexers are any ->o1 = { x: b, 0: c } : { 0: any; x: B; } +>o1 = { x: b, 0: c } : { x: B; 0: any; } >o1 : { [s: string]: A; [n: number]: B; } ->{ x: b, 0: c } : { 0: any; x: B; } +>{ x: b, 0: c } : { x: B; 0: any; } >x : B >b : B >c : any o1 = { x: c, 0: b }; // string indexer is any, number indexer is B ->o1 = { x: c, 0: b } : { 0: B; x: any; } +>o1 = { x: c, 0: b } : { x: any; 0: B; } >o1 : { [s: string]: A; [n: number]: B; } ->{ x: c, 0: b } : { 0: B; x: any; } +>{ x: c, 0: b } : { x: any; 0: B; } >x : any >c : any >b : B diff --git a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types index e050d33024c..1f34c4fafac 100644 --- a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types +++ b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types @@ -267,7 +267,7 @@ var r13 = i[-01] >01 : 1 var a: { ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } "0.1": void; ".1": Object; @@ -289,19 +289,19 @@ var a: { var r1 = a['0.1']; >r1 : void >a['0.1'] : void ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'0.1' : "0.1" var r2 = a['.1']; >r2 : Object >a['.1'] : Object ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'.1' : ".1" var r3 = a['1']; >r3 : number >a['1'] : number ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1' : "1" var r3 = c[1]; @@ -313,7 +313,7 @@ var r3 = c[1]; var r4 = a['1.']; >r4 : string >a['1.'] : string ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically @@ -325,13 +325,13 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = a['1..']; >r5 : boolean >a['1..'] : boolean ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1..' : "1.." var r6 = a['1.0']; >r6 : Date >a['1.0'] : Date ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically @@ -394,8 +394,8 @@ var r13 = i[-01] >01 : 1 var b = { ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } "0.1": null, >null : void @@ -429,19 +429,19 @@ var b = { var r1 = b['0.1']; >r1 : void >b['0.1'] : void ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'0.1' : "0.1" var r2 = b['.1']; >r2 : Object >b['.1'] : Object ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'.1' : ".1" var r3 = b['1']; >r3 : number >b['1'] : number ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1' : "1" var r3 = c[1]; @@ -453,7 +453,7 @@ var r3 = c[1]; var r4 = b['1.']; >r4 : string >b['1.'] : string ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically @@ -465,13 +465,13 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = b['1..']; >r5 : boolean >b['1..'] : boolean ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1..' : "1.." var r6 = b['1.0']; >r6 : Date >b['1.0'] : Date ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index 8f4bbe2025a..606cc39afef 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,8 +22,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. - Property '2.0' is incompatible with index signature. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. + Property 'b' is incompatible with index signature. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -157,8 +157,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. -!!! error TS2322: Property '2.0' is incompatible with index signature. +!!! error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Property 'b' is incompatible with index signature. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 745a746db11..f97e122aabb 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -43,6 +43,16 @@ // TODO: figure out a better solution to the API exposure problem. declare module ts { + export type MapKey = string | number; + export interface Map { + forEach(action: (value: T, key: string) => void): void; + get(key: MapKey): T; + has(key: MapKey): boolean; + set(key: MapKey, value: T): this; + delete(key: MapKey): boolean; + clear(): void; + } + interface SymbolDisplayPart { text: string; kind: string; @@ -103,7 +113,7 @@ declare namespace FourSlashInterface { markerNames(): string[]; marker(name?: string): Marker; ranges(): Range[]; - rangesByText(): { [text: string]: Range[] }; + rangesByText(): ts.Map; markerByName(s: string): Marker; } class goTo { diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index b05346a366a..fa9e59cabcf 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -202,15 +202,14 @@ goTo.marker("4"); verify.referencesAre([]); const rangesByText = test.rangesByText(); -for (const text in rangesByText) { - const ranges = rangesByText[text]; +rangesByText.forEach((ranges, text) => { if (text === "globalVar") { verify.rangesReferenceEachOther(ranges.filter(isShadow)); verify.rangesReferenceEachOther(ranges.filter(r => !isShadow(r))); } else { verify.rangesReferenceEachOther(ranges); } -} +}); function isShadow(r) { return r.marker && r.marker.data && r.marker.data.shadow; diff --git a/tslint.json b/tslint.json index 26657981a63..13de7acec63 100644 --- a/tslint.json +++ b/tslint.json @@ -46,6 +46,7 @@ "prefer-const": true, "no-increment-decrement": true, "object-literal-surrounding-space": true, - "no-type-assertion-whitespace": true + "no-type-assertion-whitespace": true, + "no-in-operator": true } } From b15ffda7f699097c7abf49252558dcafb3da3a50 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 8 Dec 2016 06:55:49 -0800 Subject: [PATCH 023/175] Simplify forEachKeyInMap and someKeyInMap --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 46 +++++++++-------------------------------- 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 00a6ad2c366..67c4db715e2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18991,7 +18991,7 @@ namespace ts { } function hasExportedMembers(moduleSymbol: Symbol) { - return someKeyInMap(moduleSymbol.exports, id => id !== "export="); + return someInMap(moduleSymbol.exports, (_, id) => id !== "export="); } function checkExternalModuleExports(node: SourceFile | ModuleDeclaration) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index affd225b3a7..3fe3b386701 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -68,7 +68,6 @@ namespace ts { interface ES6Map extends Map { readonly size: number; entries(): Iterator<[string, T]>; - keys(): Iterator; } /** ES6 Iterator type. */ @@ -80,9 +79,7 @@ namespace ts { interface ShimMap extends Map { isEmpty(): boolean; forEachInMap(callback: (value: T, key: string) => U | undefined): U | undefined; - forEachKey(callback: (key: string) => U | undefined): U | undefined; some(predicate: (value: T, key: string) => boolean): boolean; - someKey(predicate: (key: string) => boolean): boolean; } // The global Map object. This may not be available, so we must test for it. @@ -130,16 +127,12 @@ namespace ts { } isEmpty(): boolean { - return !this.someKey(() => true); + return !this.some(() => true); } forEachInMap(callback: (value: T, key: string) => U | undefined): U | undefined { - return this.forEachKey(key => callback(this.data[key], key)); - } - - forEachKey(callback: (key: string) => U | undefined): U | undefined { for (const key in this.data) { - const result = callback(key); + const result = callback(this.data[key], key); if (result !== undefined) { return result; } @@ -147,12 +140,8 @@ namespace ts { } some(predicate: (value: T, key: string) => boolean): boolean { - return this.someKey(key => predicate(this.data[key], key)); - } - - someKey(predicate: (key: string) => boolean): boolean { for (const key in this.data) { - if (predicate(key)) { + if (predicate(this.data[key], key)) { return true; } } @@ -939,17 +928,9 @@ namespace ts { : (map: ShimMap, callback: (value: T, key: string) => U | undefined) => map.forEachInMap(callback); /** `forEachInMap` for just keys. */ - export const forEachKeyInMap: (map: Map<{}>, callback: (key: string) => T | undefined) => T | undefined = usingNativeMaps - ? (map: ES6Map, callback: (key: string) => T | undefined) => { - const iterator = map.keys(); - while (true) { - const { value: key, done } = iterator.next(); - if (done) return undefined; - const result = callback(key); - if (result !== undefined) return result; - } - } - : (map: ShimMap, callback: (key: string) => T | undefined) => map.forEachKey(callback); + export function forEachKeyInMap(map: Map<{}>, callback: (key: string) => T | undefined): T | undefined { + return forEachInMap(map, (_, key) => callback(key)); + } /** Whether `predicate` is true for some entry in the map. */ export const someInMap: (map: Map, predicate: (value: T, key: string) => boolean) => boolean = usingNativeMaps @@ -964,17 +945,10 @@ namespace ts { } : (map: ShimMap, predicate: (value: T, key: string) => boolean) => map.some(predicate); - /** Whether `predicate` is true for some key in the map. */ - export const someKeyInMap: (map: Map<{}>, predicate: (key: string) => boolean) => boolean = usingNativeMaps - ? (map: ES6Map<{}>, predicate: (key: string) => boolean) => { - const iterator = map.keys(); - while (true) { - const { value: key, done } = iterator.next(); - if (done) return false; - if (predicate(key)) return true; - } - } - : (map: ShimMap<{}>, predicate: (key: string) => boolean) => map.someKey(predicate); + /** `someInMap` for just keys. */ + export function someKeyInMap(map: Map<{}>, predicate: (key: string) => boolean): boolean { + return someInMap(map, (_, key) => predicate(key)); + } /** Copy entries from `source` to `target`. */ export function copyMapEntries(source: Map, target: Map): void { From 863e4d6fa06b7d705592167285f17dd12981d8e8 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 8 Dec 2016 08:00:10 -0800 Subject: [PATCH 024/175] Clean up helpers --- src/compiler/core.ts | 23 +++++++------------ src/compiler/types.ts | 1 + .../unittests/reuseProgramStructure.ts | 14 +++++++++++ .../unittests/tsserverProjectSystem.ts | 10 ++------ 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 3fe3b386701..3c370f7b154 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -66,7 +66,6 @@ namespace ts { /** Methods on native maps but not on shim maps. Only used in this file. */ interface ES6Map extends Map { - readonly size: number; entries(): Iterator<[string, T]>; } @@ -130,6 +129,14 @@ namespace ts { return !this.some(() => true); } + get size(): number { + let size = 0; + for (const _ in this.data) { + size++; + } + return size; + } + forEachInMap(callback: (value: T, key: string) => U | undefined): U | undefined { for (const key in this.data) { const result = callback(this.data[key], key); @@ -988,20 +995,6 @@ namespace ts { return true; } - /** True if the maps have the same keys and values. */ - export function mapsAreEqual(left: Map, right: Map, valuesAreEqual?: (left: T, right: T) => boolean): boolean { - if (left === right) return true; - if (!left || !right) return false; - const someInLeftHasNoMatch = someInMap(left, (leftValue, leftKey) => { - if (!right.has(leftKey)) return true; - const rightValue = right.get(leftKey); - return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue); - }); - if (someInLeftHasNoMatch) return false; - const someInRightHasNoMatch = someKeyInMap(right, rightKey => !left.has(rightKey)); - return !someInRightHasNoMatch; - } - /** * Creates a map from the elements of an array. * diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 055049999ec..75e1e82e7f6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -20,6 +20,7 @@ namespace ts { clear(): void; /** `key` may *not* be a string if it was set with a number and we are not using the shim. */ forEach(action: (value: T, key: string) => void): void; + readonly size: number; } // branded string type used to store absolute, normalized and canonicalized paths diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 54c05a9c383..eb4395154e4 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -193,6 +193,20 @@ namespace ts { } } + /** True if the maps have the same keys and values. */ + function mapsAreEqual(left: Map, right: Map, valuesAreEqual?: (left: T, right: T) => boolean): boolean { + if (left === right) return true; + if (!left || !right) return false; + const someInLeftHasNoMatch = someInMap(left, (leftValue, leftKey) => { + if (!right.has(leftKey)) return true; + const rightValue = right.get(leftKey); + return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue); + }); + if (someInLeftHasNoMatch) return false; + const someInRightHasNoMatch = someKeyInMap(right, rightKey => !left.has(rightKey)); + return !someInRightHasNoMatch; + } + function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, checkResolvedModule); } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index bec3a700879..9beefe480df 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -243,18 +243,12 @@ namespace ts.projectSystem { } export function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { - assert.equal(mapSize(map), expectedKeys.length, `${caption}: incorrect size of map`); + assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${keysOfMap(map)}`); } } - function mapSize(map: Map): number { - let size = 0; - map.forEach(() => { size++; }); - return size; - } - export function checkFileNames(caption: string, actualFileNames: string[], expectedFileNames: string[]) { assert.equal(actualFileNames.length, expectedFileNames.length, `${caption}: incorrect actual number of files, expected ${JSON.stringify(expectedFileNames)}, got ${actualFileNames}`); for (const f of expectedFileNames) { @@ -313,7 +307,7 @@ namespace ts.projectSystem { } count() { - return mapSize(this.map); + return this.map.size; } invoke() { From 8121de74d47b6ea70a5b64375967a15727f95c90 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 8 Dec 2016 08:33:58 -0800 Subject: [PATCH 025/175] Fix target error for gulp --- Gulpfile.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/Gulpfile.ts b/Gulpfile.ts index 054e99c8003..7072becc2da 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -330,6 +330,7 @@ const builtGeneratedDiagnosticMessagesJSON = path.join(builtLocalDirectory, "dia // processDiagnosticMessages script gulp.task(processDiagnosticMessagesJs, false, [], () => { const settings: tsc.Settings = getCompilerSettings({ + target: "es5", declaration: false, removeComments: true, noResolve: false, From 8dbb8e7bf6ac861515670a86c23da6ae9275eda2 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 8 Dec 2016 08:34:56 -0800 Subject: [PATCH 026/175] Add comment --- 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 75e1e82e7f6..ca2295e5ba2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -11,7 +11,7 @@ namespace ts { /** It's allowed to get/set into a map with numbers. However, when iterating, you may get strings back due to the shim being an ordinary object (which only allows string keys). */ export type MapKey = string | number; - /** Minimal ES6 Map interface. */ + /** Minimal ES6 Map interface. Does not include iterators as those are hard to shim performantly. */ export interface Map { get(key: MapKey): T; has(key: MapKey): boolean; From 5c304d0d0f3d4e08d0bd11ea48a479cbc422c417 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 12 Dec 2016 08:15:55 -0800 Subject: [PATCH 027/175] Remove `createObject`; use `Object.create` directly. --- src/compiler/core.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index fd9eedeeece..4ed20bcdecf 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -26,10 +26,9 @@ namespace ts { // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - const createObject = Object.create; /** Create a MapLike with good performance. Prefer this over a literal `{}`. */ export function createMapLike(): MapLike { - const map = createObject(null); // tslint:disable-line:no-null-keyword + const map = Object.create(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is From b53b5cf4ab8f60090cc6ad764d9cfae718d3a50e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 12 Dec 2016 08:42:12 -0800 Subject: [PATCH 028/175] Remove the "set" function and use `map.set` with multiple lines of code if necessary. --- src/compiler/binder.ts | 7 ++- src/compiler/checker.ts | 52 ++++++++++++++++------ src/compiler/core.ts | 15 ++----- src/compiler/emitter.ts | 3 +- src/compiler/parser.ts | 6 ++- src/compiler/program.ts | 10 +++-- src/compiler/transformers/module/module.ts | 3 +- src/compiler/transformers/module/system.ts | 6 ++- src/compiler/tsc.ts | 7 ++- src/compiler/utilities.ts | 4 +- src/harness/harness.ts | 8 ++-- src/server/client.ts | 3 +- src/services/patternMatcher.ts | 6 ++- src/services/services.ts | 6 ++- 14 files changed, 91 insertions(+), 45 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 18a6d00e922..046b67ccd1c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -349,7 +349,10 @@ namespace ts { // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = symbolTable.get(name) || set(symbolTable, name, createSymbol(SymbolFlags.None, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); + } if (name && (includes & SymbolFlags.Classifiable)) { classifiableNames.set(name, name); @@ -359,7 +362,7 @@ namespace ts { if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbol = set(symbolTable, name, createSymbol(SymbolFlags.None, name)); + symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); } else { if (node.name) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6bbbab8822e..2394d5017a3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4062,7 +4062,8 @@ namespace ts { const memberSymbol = getSymbolOfNode(member); const value = getEnumMemberValue(member); if (!memberTypes.has(value)) { - const memberType = set(memberTypes, value, createEnumLiteralType(memberSymbol, enumType, "" + value)); + const memberType = createEnumLiteralType(memberSymbol, enumType, "" + value); + memberTypes.set(value, memberType); memberTypeList.push(memberType); } } @@ -5192,7 +5193,11 @@ namespace ts { function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); - return instantiations.get(id) || set(instantiations, id, createSignatureInstantiation(signature, typeArguments)); + let instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { @@ -5348,7 +5353,8 @@ namespace ts { const id = getTypeListId(typeArguments); let type = target.instantiations.get(id); if (!type) { - type = set(target.instantiations, id, createObjectType(ObjectFlags.Reference, target.symbol)); + type = createObjectType(ObjectFlags.Reference, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -5395,7 +5401,11 @@ namespace ts { const links = getSymbolLinks(symbol); const typeParameters = links.typeParameters; const id = getTypeListId(typeArguments); - return links.instantiations.get(id) || set(links.instantiations, id, instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + let instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + } + return instantiation; } // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include @@ -5844,7 +5854,8 @@ namespace ts { let type = unionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); - type = set(unionTypes, id, createType(TypeFlags.Union | propagatedFlags)); + type = createType(TypeFlags.Union | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -5918,7 +5929,8 @@ namespace ts { let type = intersectionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); - type = set(intersectionTypes, id, createType(TypeFlags.Intersection | propagatedFlags)); + type = createType(TypeFlags.Intersection | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -6100,7 +6112,11 @@ namespace ts { } // Otherwise we defer the operation by creating an indexed access type. const id = objectType.id + "," + indexType.id; - return indexedAccessTypes.get(id) || set(indexedAccessTypes, id, createIndexedAccessType(objectType, indexType)); + let type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } // In the following we resolve T[K] to the type of the property in T selected by K. const apparentObjectType = getApparentType(objectType); @@ -6268,7 +6284,11 @@ namespace ts { function getLiteralTypeForText(flags: TypeFlags, text: string) { const map = flags & TypeFlags.StringLiteral ? stringLiteralTypes : numericLiteralTypes; - return map.get(text) || set(map, text, createLiteralType(flags, text)); + let type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { @@ -7060,7 +7080,8 @@ namespace ts { if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & SymbolFlags.RegularEnum) || !(target.symbol.flags & SymbolFlags.RegularEnum) || (source.flags & TypeFlags.Union) !== (target.flags & TypeFlags.Union)) { - return set(enumRelation, id, false); + enumRelation.set(id, false); + return false; } const targetEnumType = getTypeOfSymbol(target.symbol); for (const property of getPropertiesOfType(getTypeOfSymbol(source.symbol))) { @@ -7071,11 +7092,13 @@ namespace ts { errorReporter(Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType)); } - return set(enumRelation, id, false); + enumRelation.set(id, false); + return false; } } } - return set(enumRelation, id, true); + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source: Type, target: Type, relation: Map, errorReporter?: ErrorReporter) { @@ -9815,7 +9838,8 @@ namespace ts { if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } - return set(cache, key, result); + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr: Expression) { @@ -11771,9 +11795,9 @@ namespace ts { } function getJsxType(name: string) { - const jsxType = jsxTypes.get(name); + let jsxType = jsxTypes.get(name); if (jsxType === undefined) { - return set(jsxTypes, name, getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } return jsxType; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4ed20bcdecf..6239dc93146 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -156,15 +156,6 @@ namespace ts { } } - /** - * Unlike `map.set(key, value)`, this returns the value, making it useful as an expression. - * Prefer `map.set(key, value)` for statements. - */ - export function set(map: Map, key: MapKey, value: T): T { - map.set(key, value); - return value; - } - export function createFileMap(keyMapper?: (key: string) => string): FileMap { const files = createMap(); return { @@ -1050,14 +1041,14 @@ namespace ts { * Creates the array if it does not already exist. */ export function multiMapAdd(map: Map, key: string | number, value: V): V[] { - const values = map.get(key); + let values = map.get(key); if (values) { values.push(value); - return values; } else { - return set(map, key, [value]); + map.set(key, values = [value]); } + return values; } /** diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 191a39a5797..00144f2d00b 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2545,7 +2545,8 @@ namespace ts { while (true) { const generatedName = baseName + i; if (isUniqueName(generatedName)) { - return set(generatedNameSet, generatedName, generatedName); + generatedNameSet.set(generatedName, generatedName); + return generatedName; } i++; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3da9093ee5a..bb53eeba0e0 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1131,7 +1131,11 @@ namespace ts { function internIdentifier(text: string): string { text = escapeIdentifier(text); - return identifiers.get(text) || set(identifiers, text, text); + let identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3da9f57ca39..ab04a21ee69 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -277,9 +277,13 @@ namespace ts { const resolutions: T[] = []; const cache = createMap(); for (const name of names) { - const result = cache.has(name) - ? cache.get(name) - : set(cache, name, loader(name, containingFile)); + let result: T; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 2e926406fb4..5d05667e4c2 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -60,7 +60,8 @@ namespace ts { } currentSourceFile = node; - currentModuleInfo = set(moduleInfoMap, getOriginalNodeId(node), collectExternalModuleInfo(node, resolver, compilerOptions)); + currentModuleInfo = collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap.set(getOriginalNodeId(node), currentModuleInfo); // Perform the transformation. const transformModule = transformModuleDelegates.get(moduleKind) || transformModuleDelegates.get(ModuleKind.None); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 8d1e1749c0b..bc613bcfaf6 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -73,11 +73,13 @@ namespace ts { // see comment to 'substitutePostfixUnaryExpression' for more details // Collect information about the external module and dependency groups. - moduleInfo = set(moduleInfoMap, id, collectExternalModuleInfo(node, resolver, compilerOptions)); + moduleInfo = collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap.set(id, moduleInfo); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. - exportFunction = set(exportFunctionsMap, id, createUniqueName("exports")); + exportFunction = createUniqueName("exports"); + exportFunctionsMap.set(id, exportFunction); contextObject = createUniqueName("context"); // Add the body of the module. diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 0e66ccb14b8..5de16a20fc2 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -378,8 +378,11 @@ namespace ts { } function cachedFileExists(fileName: string): boolean { - const fileExists = cachedExistingFiles.get(fileName); - return fileExists !== undefined ? fileExists : set(cachedExistingFiles, fileName, hostFileExists(fileName)); + let fileExists = cachedExistingFiles.get(fileName); + if (fileExists === undefined) { + cachedExistingFiles.set(fileName, fileExists = hostFileExists(fileName)); + } + return fileExists; } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 94b0fa20987..25973cae5cb 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3323,7 +3323,9 @@ namespace ts { for (const name in syntaxKindEnum) { if (syntaxKindEnum[name] === kind) { - return set(syntaxKindCache, kind, kind.toString() + " (" + name + ")"); + const result = `${kind} (${name})`; + syntaxKindCache.set(kind, result); + return result; } } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 265fe4c142c..c94a9360745 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -918,9 +918,11 @@ namespace Harness { return undefined; } - const sourceFile = libFileNameSourceFileMap.get(fileName); - return sourceFile || ts.set(libFileNameSourceFileMap, fileName, - createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest)); + let sourceFile = libFileNameSourceFileMap.get(fileName); + if (!sourceFile) { + libFileNameSourceFileMap.set(fileName, sourceFile = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest)); + } + return sourceFile; } export function getDefaultLibFileName(options: ts.CompilerOptions): string { diff --git a/src/server/client.ts b/src/server/client.ts index 13d16073d1c..d9e93769bd9 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -34,7 +34,8 @@ namespace ts.server { let lineMap = this.lineMaps.get(fileName); if (!lineMap) { const scriptSnapshot = this.host.getScriptSnapshot(fileName); - lineMap = set(this.lineMaps, fileName, ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength()))); + lineMap = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength())); + this.lineMaps.set(fileName, lineMap); } return lineMap; } diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index b8941ef3147..940290a2f94 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -188,7 +188,11 @@ namespace ts { } function getWordSpans(word: string): TextSpan[] { - return stringToWordSpans.get(word) || set(stringToWordSpans, word, breakIntoWordSpans(word)); + let spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); + } + return spans; } function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch { diff --git a/src/services/services.ts b/src/services/services.ts index 87ae9fb8561..6d0d384bcdd 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -532,7 +532,11 @@ namespace ts { } function getDeclarations(name: string) { - return result.get(name) || set(result, name, []); + let declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration: Declaration) { From ebe2fdb4c831bbd43a7873e869f072aff6dcaaaf Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Fri, 25 Nov 2016 18:54:01 +0800 Subject: [PATCH 029/175] Fix #1809, introduce non primitive type --- src/compiler/binder.ts | 2 ++ src/compiler/checker.ts | 13 +++++++++++++ src/compiler/scanner.ts | 1 + src/compiler/types.ts | 3 +++ 4 files changed, 19 insertions(+) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a6f5993f6c8..4b7d1d7b274 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -3145,6 +3145,7 @@ namespace ts { case SyntaxKind.AnyKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: @@ -3343,6 +3344,7 @@ namespace ts { case SyntaxKind.NumberKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.StringKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a27e8ba524d..39832dfcb35 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -146,6 +146,7 @@ namespace ts { const silentNeverType = createIntrinsicType(TypeFlags.Never, "never"); const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const nonPrimitiveType = createNonPrimitiveType(); const emptyTypeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral | SymbolFlags.Transient, "__type"); emptyTypeLiteralSymbol.members = createMap(); @@ -1684,6 +1685,14 @@ namespace ts { return type; } + function createNonPrimitiveType(): NonPrimitiveType { + const type = setStructuredTypeMembers( + createObjectType(ObjectFlags.NonPrimitive, undefined), + emptySymbols, emptyArray, emptyArray, undefined, undefined); + type.intrinsicName = "object"; + return type; + } + function createObjectType(objectFlags: ObjectFlags, symbol?: Symbol): ObjectType { const type = createType(TypeFlags.Object); type.objectFlags = objectFlags; @@ -4178,6 +4187,7 @@ namespace ts { case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NullKeyword: @@ -6384,6 +6394,8 @@ namespace ts { return nullType; case SyntaxKind.NeverKeyword: return neverType; + case SyntaxKind.ObjectKeyword: + return nonPrimitiveType; case SyntaxKind.JSDocNullKeyword: return nullType; case SyntaxKind.JSDocUndefinedKeyword: @@ -7139,6 +7151,7 @@ namespace ts { if (source.flags & TypeFlags.Enum && target.flags & TypeFlags.Enum && isEnumTypeRelatedTo(source, target, errorReporter)) return true; if (source.flags & TypeFlags.Undefined && (!strictNullChecks || target.flags & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true; + if (source.flags & TypeFlags.Object && (source).objectFlags & ObjectFlags.NonPrimitive && target.flags & TypeFlags.Primitive) return false; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & TypeFlags.Any) return true; if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 82302e98e37..ad8781aecec 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -98,6 +98,7 @@ namespace ts { "new": SyntaxKind.NewKeyword, "null": SyntaxKind.NullKeyword, "number": SyntaxKind.NumberKeyword, + "object": SyntaxKind.ObjectKeyword, "package": SyntaxKind.PackageKeyword, "private": SyntaxKind.PrivateKeyword, "protected": SyntaxKind.ProtectedKeyword, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1ee59149b2c..db919b56449 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -175,6 +175,7 @@ namespace ts { ReadonlyKeyword, RequireKeyword, NumberKeyword, + ObjectKeyword, SetKeyword, StringKeyword, SymbolKeyword, @@ -816,6 +817,7 @@ namespace ts { export interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword + | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword @@ -2857,6 +2859,7 @@ namespace ts { ObjectLiteral = 1 << 7, // Originates in an object literal EvolvingArray = 1 << 8, // Evolving array type ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties + NonPrimitive = 1 << 10, // NonPrimitive object type ClassOrInterface = Class | Interface } From db9dd387b169475239a22dac398bcc8dc2cf887a Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Fri, 25 Nov 2016 20:20:15 +0800 Subject: [PATCH 030/175] enable parsing --- src/compiler/parser.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2f0d6a4d975..5bf9ce789c1 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2507,6 +2507,7 @@ namespace ts { case SyntaxKind.SymbolKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: // If these are followed by a dot, then parse these out as a dotted type reference instead. const node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -2565,6 +2566,7 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: + case SyntaxKind.ObjectKeyword: return true; case SyntaxKind.MinusToken: return lookAhead(nextTokenIsNumericLiteral); @@ -6026,6 +6028,7 @@ namespace ts { case SyntaxKind.NullKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: return parseTokenNode(); case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: From ce4c95f332975ea5c2fd18e5c17bf4443056b5b1 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Fri, 25 Nov 2016 22:24:31 +0800 Subject: [PATCH 031/175] fix error reporting --- src/compiler/checker.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 39832dfcb35..c863e2fd2c7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1685,11 +1685,10 @@ namespace ts { return type; } - function createNonPrimitiveType(): NonPrimitiveType { - const type = setStructuredTypeMembers( + function createNonPrimitiveType(): ResolvedType { + const type = setStructuredTypeMembers( createObjectType(ObjectFlags.NonPrimitive, undefined), emptySymbols, emptyArray, emptyArray, undefined, undefined); - type.intrinsicName = "object"; return type; } @@ -2321,6 +2320,9 @@ namespace ts { else if (type.flags & TypeFlags.UnionOrIntersection) { writeUnionOrIntersectionType(type, nextFlags); } + else if (getObjectFlags(type) & ObjectFlags.NonPrimitive) { + writer.writeKeyword("object"); + } else if (getObjectFlags(type) & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { writeAnonymousType(type, nextFlags); } @@ -3087,6 +3089,10 @@ namespace ts { return type && (type.flags & TypeFlags.Never) !== 0; } + function isTypeNonPrimitive(type: Type) { + return type === nonPrimitiveType; + } + // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node: VariableLikeDeclaration) { @@ -7151,7 +7157,6 @@ namespace ts { if (source.flags & TypeFlags.Enum && target.flags & TypeFlags.Enum && isEnumTypeRelatedTo(source, target, errorReporter)) return true; if (source.flags & TypeFlags.Undefined && (!strictNullChecks || target.flags & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true; - if (source.flags & TypeFlags.Object && (source).objectFlags & ObjectFlags.NonPrimitive && target.flags & TypeFlags.Primitive) return false; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & TypeFlags.Any) return true; if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true; @@ -7470,7 +7475,7 @@ namespace ts { } } } - else { + else if (!(source.flags & TypeFlags.Primitive && isTypeNonPrimitive(target))) { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if relationship holds for all type arguments if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { @@ -18085,6 +18090,7 @@ namespace ts { case "string": case "symbol": case "void": + case "object": error(name, message, (name).text); } } From b8648fa9f63e7fd55e1793a96ab9bfaf4d483451 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Sat, 26 Nov 2016 00:32:55 +0800 Subject: [PATCH 032/175] add tests for non primitive type --- .../reference/assignObjectToNonPrimitive.js | 14 ++++++ .../assignObjectToNonPrimitive.symbols | 19 ++++++++ .../assignObjectToNonPrimitive.types | 24 ++++++++++ .../nonPriimitiveInFunction.errors.txt | 31 +++++++++++++ .../reference/nonPriimitiveInFunction.js | 36 +++++++++++++++ .../nonPrimitiveAsProperty.errors.txt | 18 ++++++++ .../reference/nonPrimitiveAsProperty.js | 13 ++++++ .../nonPrimitiveAssignError.errors.txt | 44 +++++++++++++++++++ .../reference/nonPrimitiveAssignError.js | 35 +++++++++++++++ .../nonPrimitiveInGeneric.errors.txt | 31 +++++++++++++ .../reference/nonPrimitiveInGeneric.js | 31 +++++++++++++ .../nonPrimitiveUnionIntersection.errors.txt | 18 ++++++++ .../nonPrimitiveUnionIntersection.js | 12 +++++ .../reservedNamesInAliases.errors.txt | 9 +++- .../reference/reservedNamesInAliases.js | 4 +- .../assignObjectToNonPrimitive.ts | 5 +++ .../nonPrimitive/nonPriimitiveInFunction.ts | 18 ++++++++ .../nonPrimitive/nonPrimitiveAsProperty.ts | 7 +++ .../nonPrimitive/nonPrimitiveAssignError.ts | 17 +++++++ .../nonPrimitive/nonPrimitiveInGeneric.ts | 15 +++++++ .../nonPrimitiveUnionIntersection.ts | 4 ++ .../typeAliases/reservedNamesInAliases.ts | 3 +- 22 files changed, 404 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/assignObjectToNonPrimitive.js create mode 100644 tests/baselines/reference/assignObjectToNonPrimitive.symbols create mode 100644 tests/baselines/reference/assignObjectToNonPrimitive.types create mode 100644 tests/baselines/reference/nonPriimitiveInFunction.errors.txt create mode 100644 tests/baselines/reference/nonPriimitiveInFunction.js create mode 100644 tests/baselines/reference/nonPrimitiveAsProperty.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveAsProperty.js create mode 100644 tests/baselines/reference/nonPrimitiveAssignError.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveAssignError.js create mode 100644 tests/baselines/reference/nonPrimitiveInGeneric.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveInGeneric.js create mode 100644 tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveUnionIntersection.js create mode 100644 tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.js b/tests/baselines/reference/assignObjectToNonPrimitive.js new file mode 100644 index 00000000000..ec0015fba8a --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.js @@ -0,0 +1,14 @@ +//// [assignObjectToNonPrimitive.ts] +var x = {}; +var y = {foo: "bar"}; +var a: object; +a = x; +a = y; + + +//// [assignObjectToNonPrimitive.js] +var x = {}; +var y = { foo: "bar" }; +var a; +a = x; +a = y; diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.symbols b/tests/baselines/reference/assignObjectToNonPrimitive.symbols new file mode 100644 index 00000000000..5c806e09b94 --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts === +var x = {}; +>x : Symbol(x, Decl(assignObjectToNonPrimitive.ts, 0, 3)) + +var y = {foo: "bar"}; +>y : Symbol(y, Decl(assignObjectToNonPrimitive.ts, 1, 3)) +>foo : Symbol(foo, Decl(assignObjectToNonPrimitive.ts, 1, 9)) + +var a: object; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) + +a = x; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) +>x : Symbol(x, Decl(assignObjectToNonPrimitive.ts, 0, 3)) + +a = y; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) +>y : Symbol(y, Decl(assignObjectToNonPrimitive.ts, 1, 3)) + diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.types b/tests/baselines/reference/assignObjectToNonPrimitive.types new file mode 100644 index 00000000000..f16c2287155 --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts === +var x = {}; +>x : {} +>{} : {} + +var y = {foo: "bar"}; +>y : { foo: string; } +>{foo: "bar"} : { foo: string; } +>foo : string +>"bar" : "bar" + +var a: object; +>a : object + +a = x; +>a = x : {} +>a : object +>x : {} + +a = y; +>a = y : { foo: string; } +>a : object +>y : { foo: string; } + diff --git a/tests/baselines/reference/nonPriimitiveInFunction.errors.txt b/tests/baselines/reference/nonPriimitiveInFunction.errors.txt new file mode 100644 index 00000000000..4b244cfcd04 --- /dev/null +++ b/tests/baselines/reference/nonPriimitiveInFunction.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts(12,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts(13,1): error TS2322: Type 'object' is not assignable to type 'boolean'. +tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts(17,12): error TS2322: Type 'number' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts (3 errors) ==== + function takeObject(o: object) {} + function returnObject(): object { + return {}; + } + + var nonPrimitive: object; + var primitive: boolean; + + takeObject(nonPrimitive); + nonPrimitive = returnObject(); + + takeObject(primitive); // expect error + ~~~~~~~~~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. + primitive = returnObject(); // expect error + ~~~~~~~~~ +!!! error TS2322: Type 'object' is not assignable to type 'boolean'. + + function returnError(): object { + var ret = 123; + return ret; // expect error + ~~~ +!!! error TS2322: Type 'number' is not assignable to type 'object'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPriimitiveInFunction.js b/tests/baselines/reference/nonPriimitiveInFunction.js new file mode 100644 index 00000000000..a534ea7c84e --- /dev/null +++ b/tests/baselines/reference/nonPriimitiveInFunction.js @@ -0,0 +1,36 @@ +//// [nonPriimitiveInFunction.ts] +function takeObject(o: object) {} +function returnObject(): object { + return {}; +} + +var nonPrimitive: object; +var primitive: boolean; + +takeObject(nonPrimitive); +nonPrimitive = returnObject(); + +takeObject(primitive); // expect error +primitive = returnObject(); // expect error + +function returnError(): object { + var ret = 123; + return ret; // expect error +} + + +//// [nonPriimitiveInFunction.js] +function takeObject(o) { } +function returnObject() { + return {}; +} +var nonPrimitive; +var primitive; +takeObject(nonPrimitive); +nonPrimitive = returnObject(); +takeObject(primitive); // expect error +primitive = returnObject(); // expect error +function returnError() { + var ret = 123; + return ret; // expect error +} diff --git a/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt b/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt new file mode 100644 index 00000000000..8d4042c92f0 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts(7,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'WithNonPrimitive'. + Types of property 'foo' are incompatible. + Type 'string' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts (1 errors) ==== + interface WithNonPrimitive { + foo: object + } + + var a: WithNonPrimitive = { foo: {bar: "bar"} }; + + var b: WithNonPrimitive = {foo: "bar"}; // expect error + ~ +!!! error TS2322: Type '{ foo: string; }' is not assignable to type 'WithNonPrimitive'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'object'. + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAsProperty.js b/tests/baselines/reference/nonPrimitiveAsProperty.js new file mode 100644 index 00000000000..f51a9b35435 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAsProperty.js @@ -0,0 +1,13 @@ +//// [nonPrimitiveAsProperty.ts] +interface WithNonPrimitive { + foo: object +} + +var a: WithNonPrimitive = { foo: {bar: "bar"} }; + +var b: WithNonPrimitive = {foo: "bar"}; // expect error + + +//// [nonPrimitiveAsProperty.js] +var a = { foo: { bar: "bar" } }; +var b = { foo: "bar" }; // expect error diff --git a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt new file mode 100644 index 00000000000..4fdd4649824 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(5,1): error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. + Property 'foo' is missing in type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(11,1): error TS2322: Type 'number' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(12,1): error TS2322: Type 'true' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(13,1): error TS2322: Type 'string' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(15,1): error TS2322: Type 'object' is not assignable to type 'number'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(16,1): error TS2322: Type 'object' is not assignable to type 'boolean'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): error TS2322: Type 'object' is not assignable to type 'string'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts (7 errors) ==== + var x = {}; + var y = {foo: "bar"}; + var a: object; + x = a; + y = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. +!!! error TS2322: Property 'foo' is missing in type 'object'. + + var n = 123; + var b = true; + var s = "fooo"; + + a = n; // expect error + ~ +!!! error TS2322: Type 'number' is not assignable to type 'object'. + a = b; // expect error + ~ +!!! error TS2322: Type 'true' is not assignable to type 'object'. + a = s; // expect error + ~ +!!! error TS2322: Type 'string' is not assignable to type 'object'. + + n = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'number'. + b = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'boolean'. + s = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAssignError.js b/tests/baselines/reference/nonPrimitiveAssignError.js new file mode 100644 index 00000000000..67f21bcf178 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAssignError.js @@ -0,0 +1,35 @@ +//// [nonPrimitiveAssignError.ts] +var x = {}; +var y = {foo: "bar"}; +var a: object; +x = a; +y = a; // expect error + +var n = 123; +var b = true; +var s = "fooo"; + +a = n; // expect error +a = b; // expect error +a = s; // expect error + +n = a; // expect error +b = a; // expect error +s = a; // expect error + + +//// [nonPrimitiveAssignError.js] +var x = {}; +var y = { foo: "bar" }; +var a; +x = a; +y = a; // expect error +var n = 123; +var b = true; +var s = "fooo"; +a = n; // expect error +a = b; // expect error +a = s; // expect error +n = a; // expect error +b = a; // expect error +s = a; // expect error diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt new file mode 100644 index 00000000000..db359cd43af --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(7,17): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(8,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(14,7): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (4 errors) ==== + function generic(t: T) {} + var a = {}; + var b = "42"; + + generic({}); + generic(a); + generic(123); // expect error + ~~~ +!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. + generic(b); // expect error + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. + + function bound(t: T) {} + + bound({}); + bound(a); + bound(123); // expect error + ~~~ +!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. + bound(b); // expect error + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.js b/tests/baselines/reference/nonPrimitiveInGeneric.js new file mode 100644 index 00000000000..82439509234 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInGeneric.js @@ -0,0 +1,31 @@ +//// [nonPrimitiveInGeneric.ts] +function generic(t: T) {} +var a = {}; +var b = "42"; + +generic({}); +generic(a); +generic(123); // expect error +generic(b); // expect error + +function bound(t: T) {} + +bound({}); +bound(a); +bound(123); // expect error +bound(b); // expect error + + +//// [nonPrimitiveInGeneric.js] +function generic(t) { } +var a = {}; +var b = "42"; +generic({}); +generic(a); +generic(123); // expect error +generic(b); // expect error +function bound(t) { } +bound({}); +bound(a); +bound(123); // expect error +bound(b); // expect error diff --git a/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt b/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt new file mode 100644 index 00000000000..5fb1e89c2e3 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(1,5): error TS2322: Type '""' is not assignable to type 'object & string'. + Type '""' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(3,1): error TS2322: Type 'string' is not assignable to type 'object & string'. + Type 'string' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts (2 errors) ==== + var a: object & string = ""; // error + ~ +!!! error TS2322: Type '""' is not assignable to type 'object & string'. +!!! error TS2322: Type '""' is not assignable to type 'object'. + var b: object | string = ""; // ok + a = b; // error + ~ +!!! error TS2322: Type 'string' is not assignable to type 'object & string'. +!!! error TS2322: Type 'string' is not assignable to type 'object'. + b = a; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveUnionIntersection.js b/tests/baselines/reference/nonPrimitiveUnionIntersection.js new file mode 100644 index 00000000000..c50a2330018 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveUnionIntersection.js @@ -0,0 +1,12 @@ +//// [nonPrimitiveUnionIntersection.ts] +var a: object & string = ""; // error +var b: object | string = ""; // ok +a = b; // error +b = a; // ok + + +//// [nonPrimitiveUnionIntersection.js] +var a = ""; // error +var b = ""; // ok +a = b; // error +b = a; // ok diff --git a/tests/baselines/reference/reservedNamesInAliases.errors.txt b/tests/baselines/reference/reservedNamesInAliases.errors.txt index b6565427395..22894f8f6a6 100644 --- a/tests/baselines/reference/reservedNamesInAliases.errors.txt +++ b/tests/baselines/reference/reservedNamesInAliases.errors.txt @@ -6,9 +6,10 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2693: 'I' only refers to a type, but is being used as a value here. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(7,6): error TS2457: Type alias name cannot be 'object' -==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (8 errors) ==== +==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (9 errors) ==== interface I {} type any = I; ~~~ @@ -30,4 +31,8 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error ~ !!! error TS1109: Expression expected. ~ -!!! error TS2693: 'I' only refers to a type, but is being used as a value here. \ No newline at end of file +!!! error TS2693: 'I' only refers to a type, but is being used as a value here. + type object = I; + ~~~~~~ +!!! error TS2457: Type alias name cannot be 'object' + \ No newline at end of file diff --git a/tests/baselines/reference/reservedNamesInAliases.js b/tests/baselines/reference/reservedNamesInAliases.js index 4ebc3bdb95f..368331d3114 100644 --- a/tests/baselines/reference/reservedNamesInAliases.js +++ b/tests/baselines/reference/reservedNamesInAliases.js @@ -4,7 +4,9 @@ type any = I; type number = I; type boolean = I; type string = I; -type void = I; +type void = I; +type object = I; + //// [reservedNamesInAliases.js] type; diff --git a/tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts b/tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts new file mode 100644 index 00000000000..e9dcb5671c5 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts @@ -0,0 +1,5 @@ +var x = {}; +var y = {foo: "bar"}; +var a: object; +a = x; +a = y; diff --git a/tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts b/tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts new file mode 100644 index 00000000000..c38693dbfb1 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts @@ -0,0 +1,18 @@ +function takeObject(o: object) {} +function returnObject(): object { + return {}; +} + +var nonPrimitive: object; +var primitive: boolean; + +takeObject(nonPrimitive); +nonPrimitive = returnObject(); + +takeObject(primitive); // expect error +primitive = returnObject(); // expect error + +function returnError(): object { + var ret = 123; + return ret; // expect error +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts new file mode 100644 index 00000000000..ee4011ecf7d --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts @@ -0,0 +1,7 @@ +interface WithNonPrimitive { + foo: object +} + +var a: WithNonPrimitive = { foo: {bar: "bar"} }; + +var b: WithNonPrimitive = {foo: "bar"}; // expect error diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts new file mode 100644 index 00000000000..f177b5cd255 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts @@ -0,0 +1,17 @@ +var x = {}; +var y = {foo: "bar"}; +var a: object; +x = a; +y = a; // expect error + +var n = 123; +var b = true; +var s = "fooo"; + +a = n; // expect error +a = b; // expect error +a = s; // expect error + +n = a; // expect error +b = a; // expect error +s = a; // expect error diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts new file mode 100644 index 00000000000..0e7914ab715 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts @@ -0,0 +1,15 @@ +function generic(t: T) {} +var a = {}; +var b = "42"; + +generic({}); +generic(a); +generic(123); // expect error +generic(b); // expect error + +function bound(t: T) {} + +bound({}); +bound(a); +bound(123); // expect error +bound(b); // expect error diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts new file mode 100644 index 00000000000..c1667c7a32e --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts @@ -0,0 +1,4 @@ +var a: object & string = ""; // error +var b: object | string = ""; // ok +a = b; // error +b = a; // ok diff --git a/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts b/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts index 3b115573830..f2c6476bd8e 100644 --- a/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts +++ b/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts @@ -3,4 +3,5 @@ type any = I; type number = I; type boolean = I; type string = I; -type void = I; \ No newline at end of file +type void = I; +type object = I; From 2fb51e71125a9100c69c8673f3adb65ecbb5be81 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Sat, 26 Nov 2016 12:49:55 +0800 Subject: [PATCH 033/175] address code review feedback --- src/compiler/checker.ts | 6 +-- .../nonPrimitiveAccessProperty.ts | 3 ++ .../nonPrimitive/nonPrimitiveAssignError.ts | 8 ++++ .../nonPrimitive/nonPrimitiveInGeneric.ts | 7 +++ .../types/nonPrimitive/nonPrimitiveNarrow.ts | 22 +++++++++ .../nonPrimitive/nonPrimitiveStrictNull.ts | 48 +++++++++++++++++++ 6 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c863e2fd2c7..a1fae5ebbd3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3089,10 +3089,6 @@ namespace ts { return type && (type.flags & TypeFlags.Never) !== 0; } - function isTypeNonPrimitive(type: Type) { - return type === nonPrimitiveType; - } - // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node: VariableLikeDeclaration) { @@ -7475,7 +7471,7 @@ namespace ts { } } } - else if (!(source.flags & TypeFlags.Primitive && isTypeNonPrimitive(target))) { + else if (!(source.flags & TypeFlags.Primitive && target === nonPrimitiveType)) { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if relationship holds for all type arguments if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts new file mode 100644 index 00000000000..2febbb1e2ca --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts @@ -0,0 +1,3 @@ +var a: object; +a.toString(); +a.nonExist(); // error diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts index f177b5cd255..8fe8c8a3ebb 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts @@ -15,3 +15,11 @@ a = s; // expect error n = a; // expect error b = a; // expect error s = a; // expect error + +var numObj: Number = 123; +var boolObj: Boolean = true; +var strObj: String = "string"; + +a = numObj; // ok +a = boolObj; // ok +a = strObj; // ok diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts index 0e7914ab715..0de4771a5ef 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts @@ -13,3 +13,10 @@ bound({}); bound(a); bound(123); // expect error bound(b); // expect error + +function bound2() {} + +bound2<{}>(); +bound2(); +bound2(); // expect error +bound2(); // expect error diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts new file mode 100644 index 00000000000..04f7351290e --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts @@ -0,0 +1,22 @@ +class Narrow { + narrowed: boolean +} + +var a: object + +if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error +} + +if (typeof a === 'number') { + a.toFixed(); // error, never +} + +var b: object | null + +if (typeof b === 'object') { + b.toString(); // error, object | null +} else { + b.toString(); // error, never +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts new file mode 100644 index 00000000000..5fbf85dc01b --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts @@ -0,0 +1,48 @@ +// @strictNullChecks: true + +var a: object +declare var b: object | null +declare var c: object | undefined +declare var d: object | null | undefined +var e: object | null +a.toString; // error +a = undefined; // error +a = null; // error +a = b; // error +a = c; // error +a = d; // error + +e = a; // ok +a = e; // ok + +if (typeof b !== 'object') { + b.toString(); // error, never +} + +if (typeof b === 'object') { + a = b; // error, b is not narrowed +} + +if (typeof d === 'object') { + b = d; // ok +} else { + d; // undefined +} + +if (d == null) { + d; // null | undefined +} else { + d.toString(); // object +} + +if (d === null) { + d; // null +} else { + d.toString(); // error, object | undefined +} + +if (typeof d === 'undefined') { + d; // undefined +} else { + d.toString(); // error, object | null +} From c19221cb3e90dc8064a240731ca77e05d3eb5fae Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Sat, 26 Nov 2016 13:09:20 +0800 Subject: [PATCH 034/175] accept new baselines --- .../nonPrimitiveAccessProperty.errors.txt | 10 ++ .../reference/nonPrimitiveAccessProperty.js | 10 ++ .../nonPrimitiveAssignError.errors.txt | 8 ++ .../reference/nonPrimitiveAssignError.js | 14 +++ .../nonPrimitiveInGeneric.errors.txt | 15 ++- .../reference/nonPrimitiveInGeneric.js | 12 ++ .../reference/nonPrimitiveNarrow.errors.txt | 35 ++++++ .../baselines/reference/nonPrimitiveNarrow.js | 46 +++++++ .../nonPrimitiveStrictNull.errors.txt | 117 ++++++++++++++++++ .../reference/nonPrimitiveStrictNull.js | 93 ++++++++++++++ .../types/nonPrimitive/nonPrimitiveNarrow.ts | 2 +- .../nonPrimitive/nonPrimitiveStrictNull.ts | 9 +- 12 files changed, 365 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveAccessProperty.js create mode 100644 tests/baselines/reference/nonPrimitiveNarrow.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveNarrow.js create mode 100644 tests/baselines/reference/nonPrimitiveStrictNull.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveStrictNull.js diff --git a/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt b/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt new file mode 100644 index 00000000000..8ef94c64448 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(3,3): error TS2339: Property 'nonExist' does not exist on type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (1 errors) ==== + var a: object; + a.toString(); + a.nonExist(); // error + ~~~~~~~~ +!!! error TS2339: Property 'nonExist' does not exist on type 'object'. + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAccessProperty.js b/tests/baselines/reference/nonPrimitiveAccessProperty.js new file mode 100644 index 00000000000..a71b2aba865 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAccessProperty.js @@ -0,0 +1,10 @@ +//// [nonPrimitiveAccessProperty.ts] +var a: object; +a.toString(); +a.nonExist(); // error + + +//// [nonPrimitiveAccessProperty.js] +var a; +a.toString(); +a.nonExist(); // error diff --git a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt index 4fdd4649824..093445570fe 100644 --- a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt +++ b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt @@ -41,4 +41,12 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): err s = a; // expect error ~ !!! error TS2322: Type 'object' is not assignable to type 'string'. + + var numObj: Number = 123; + var boolObj: Boolean = true; + var strObj: String = "string"; + + a = numObj; // ok + a = boolObj; // ok + a = strObj; // ok \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAssignError.js b/tests/baselines/reference/nonPrimitiveAssignError.js index 67f21bcf178..e7bb56746ca 100644 --- a/tests/baselines/reference/nonPrimitiveAssignError.js +++ b/tests/baselines/reference/nonPrimitiveAssignError.js @@ -16,6 +16,14 @@ a = s; // expect error n = a; // expect error b = a; // expect error s = a; // expect error + +var numObj: Number = 123; +var boolObj: Boolean = true; +var strObj: String = "string"; + +a = numObj; // ok +a = boolObj; // ok +a = strObj; // ok //// [nonPrimitiveAssignError.js] @@ -33,3 +41,9 @@ a = s; // expect error n = a; // expect error b = a; // expect error s = a; // expect error +var numObj = 123; +var boolObj = true; +var strObj = "string"; +a = numObj; // ok +a = boolObj; // ok +a = strObj; // ok diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt index db359cd43af..ab8786c37bc 100644 --- a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt +++ b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt @@ -2,9 +2,11 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(7,17): error tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(8,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(14,7): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(21,8): error TS2344: Type 'number' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(22,8): error TS2344: Type 'string' does not satisfy the constraint 'object'. -==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (4 errors) ==== +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (6 errors) ==== function generic(t: T) {} var a = {}; var b = "42"; @@ -28,4 +30,15 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error bound(b); // expect error ~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. + + function bound2() {} + + bound2<{}>(); + bound2(); + bound2(); // expect error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + bound2(); // expect error + ~~~~~~ +!!! error TS2344: Type 'string' does not satisfy the constraint 'object'. \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.js b/tests/baselines/reference/nonPrimitiveInGeneric.js index 82439509234..c2e19dde1e4 100644 --- a/tests/baselines/reference/nonPrimitiveInGeneric.js +++ b/tests/baselines/reference/nonPrimitiveInGeneric.js @@ -14,6 +14,13 @@ bound({}); bound(a); bound(123); // expect error bound(b); // expect error + +function bound2() {} + +bound2<{}>(); +bound2(); +bound2(); // expect error +bound2(); // expect error //// [nonPrimitiveInGeneric.js] @@ -29,3 +36,8 @@ bound({}); bound(a); bound(123); // expect error bound(b); // expect error +function bound2() { } +bound2(); +bound2(); +bound2(); // expect error +bound2(); // expect error diff --git a/tests/baselines/reference/nonPrimitiveNarrow.errors.txt b/tests/baselines/reference/nonPrimitiveNarrow.errors.txt new file mode 100644 index 00000000000..1b3cf55b4b2 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveNarrow.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(9,5): error TS2322: Type '123' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(13,7): error TS2339: Property 'toFixed' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(21,6): error TS2339: Property 'toString' does not exist on type 'never'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts (3 errors) ==== + class Narrow { + narrowed: boolean + } + + var a: object + + if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error + ~ +!!! error TS2322: Type '123' is not assignable to type 'object'. + } + + if (typeof a === 'number') { + a.toFixed(); // error, never + ~~~~~~~ +!!! error TS2339: Property 'toFixed' does not exist on type 'never'. + } + + var b: object | null + + if (typeof b === 'object') { + b.toString(); // ok, object | null + } else { + b.toString(); // error, never + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveNarrow.js b/tests/baselines/reference/nonPrimitiveNarrow.js new file mode 100644 index 00000000000..607206eecfc --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveNarrow.js @@ -0,0 +1,46 @@ +//// [nonPrimitiveNarrow.ts] +class Narrow { + narrowed: boolean +} + +var a: object + +if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error +} + +if (typeof a === 'number') { + a.toFixed(); // error, never +} + +var b: object | null + +if (typeof b === 'object') { + b.toString(); // ok, object | null +} else { + b.toString(); // error, never +} + + +//// [nonPrimitiveNarrow.js] +var Narrow = (function () { + function Narrow() { + } + return Narrow; +}()); +var a; +if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error +} +if (typeof a === 'number') { + a.toFixed(); // error, never +} +var b; +if (typeof b === 'object') { + b.toString(); // ok, object | null +} +else { + b.toString(); // error, never +} diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt new file mode 100644 index 00000000000..cf09994888b --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt @@ -0,0 +1,117 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(7,1): error TS2454: Variable 'a' is used before being assigned. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(8,1): error TS2322: Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(9,1): error TS2322: Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(10,1): error TS2322: Type 'object | null' is not assignable to type 'object'. + Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(11,1): error TS2322: Type 'object | undefined' is not assignable to type 'object'. + Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(12,1): error TS2322: Type 'object | null | undefined' is not assignable to type 'object'. + Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(18,7): error TS2339: Property 'toString' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(22,5): error TS2322: Type 'object | null' is not assignable to type 'object'. + Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(27,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,7): error TS2339: Property 'toString' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,5): error TS2533: Object is possibly 'null' or 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,7): error TS2339: Property 'toString' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,7): error TS2339: Property 'toString' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(41,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,7): error TS2339: Property 'toString' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (19 errors) ==== + + var a: object + declare var b: object | null + declare var c: object | undefined + declare var d: object | null | undefined + var e: object | null + a.toString; // error + ~ +!!! error TS2454: Variable 'a' is used before being assigned. + a = undefined; // error + ~ +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + a = null; // error + ~ +!!! error TS2322: Type 'null' is not assignable to type 'object'. + a = b; // error + ~ +!!! error TS2322: Type 'object | null' is not assignable to type 'object'. +!!! error TS2322: Type 'null' is not assignable to type 'object'. + a = c; // error + ~ +!!! error TS2322: Type 'object | undefined' is not assignable to type 'object'. +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + a = d; // error + ~ +!!! error TS2322: Type 'object | null | undefined' is not assignable to type 'object'. +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + + e = a; // ok + a = e; // ok + + if (typeof b !== 'object') { + b.toString(); // error, never + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } + + if (typeof b === 'object') { + a = b; // error, b is not narrowed + ~ +!!! error TS2322: Type 'object | null' is not assignable to type 'object'. +!!! error TS2322: Type 'null' is not assignable to type 'object'. + } + + if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null + ~ +!!! error TS2531: Object is possibly 'null'. + } else { + d.toString(); // error, undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } + + if (d == null) { + d.toString(); // error, undefined | null + ~ +!!! error TS2533: Object is possibly 'null' or 'undefined'. + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } else { + d.toString(); // object + } + + if (d === null) { + d.toString(); // error, null + ~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } else { + d.toString(); // error, object | undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + + if (typeof d === 'undefined') { + d.toString(); // error, undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } else { + d.toString(); // error, object | null + ~ +!!! error TS2531: Object is possibly 'null'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.js b/tests/baselines/reference/nonPrimitiveStrictNull.js new file mode 100644 index 00000000000..c91097de960 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveStrictNull.js @@ -0,0 +1,93 @@ +//// [nonPrimitiveStrictNull.ts] + +var a: object +declare var b: object | null +declare var c: object | undefined +declare var d: object | null | undefined +var e: object | null +a.toString; // error +a = undefined; // error +a = null; // error +a = b; // error +a = c; // error +a = d; // error + +e = a; // ok +a = e; // ok + +if (typeof b !== 'object') { + b.toString(); // error, never +} + +if (typeof b === 'object') { + a = b; // error, b is not narrowed +} + +if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null +} else { + d.toString(); // error, undefined +} + +if (d == null) { + d.toString(); // error, undefined | null +} else { + d.toString(); // object +} + +if (d === null) { + d.toString(); // error, null +} else { + d.toString(); // error, object | undefined +} + +if (typeof d === 'undefined') { + d.toString(); // error, undefined +} else { + d.toString(); // error, object | null +} + + +//// [nonPrimitiveStrictNull.js] +var a; +var e; +a.toString; // error +a = undefined; // error +a = null; // error +a = b; // error +a = c; // error +a = d; // error +e = a; // ok +a = e; // ok +if (typeof b !== 'object') { + b.toString(); // error, never +} +if (typeof b === 'object') { + a = b; // error, b is not narrowed +} +if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null +} +else { + d.toString(); // error, undefined +} +if (d == null) { + d.toString(); // error, undefined | null +} +else { + d.toString(); // object +} +if (d === null) { + d.toString(); // error, null +} +else { + d.toString(); // error, object | undefined +} +if (typeof d === 'undefined') { + d.toString(); // error, undefined +} +else { + d.toString(); // error, object | null +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts index 04f7351290e..2df691958de 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts @@ -16,7 +16,7 @@ if (typeof a === 'number') { var b: object | null if (typeof b === 'object') { - b.toString(); // error, object | null + b.toString(); // ok, object | null } else { b.toString(); // error, never } diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts index 5fbf85dc01b..78f2d5ff7ba 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts @@ -25,24 +25,25 @@ if (typeof b === 'object') { if (typeof d === 'object') { b = d; // ok + d.toString(); // error, object | null } else { - d; // undefined + d.toString(); // error, undefined } if (d == null) { - d; // null | undefined + d.toString(); // error, undefined | null } else { d.toString(); // object } if (d === null) { - d; // null + d.toString(); // error, null } else { d.toString(); // error, object | undefined } if (typeof d === 'undefined') { - d; // undefined + d.toString(); // error, undefined } else { d.toString(); // error, object | null } From 186ce38c180ed0670cccd4b60be06ee6b110b533 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Sat, 26 Nov 2016 13:19:04 +0800 Subject: [PATCH 035/175] add tests for generic type argument under strict null checks --- .../nonPrimitiveInGeneric.errors.txt | 18 ++++++++++++++- .../reference/nonPrimitiveInGeneric.js | 17 ++++++++++++++ .../nonPrimitiveStrictNull.errors.txt | 23 ++++++++++++++++++- .../reference/nonPrimitiveStrictNull.js | 16 +++++++++++++ .../nonPrimitive/nonPrimitiveInGeneric.ts | 13 +++++++++++ .../nonPrimitive/nonPrimitiveStrictNull.ts | 12 ++++++++++ 6 files changed, 97 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt index ab8786c37bc..04d4ee4a1a7 100644 --- a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt +++ b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt @@ -4,9 +4,10 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(14,7): error tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(21,8): error TS2344: Type 'number' does not satisfy the constraint 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(22,8): error TS2344: Type 'string' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(26,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. -==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (6 errors) ==== +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (7 errors) ==== function generic(t: T) {} var a = {}; var b = "42"; @@ -41,4 +42,19 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(22,8): error bound2(); // expect error ~~~~~~ !!! error TS2344: Type 'string' does not satisfy the constraint 'object'. + + interface Proxy {} + + var x: Proxy; // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + var y: Proxy; // ok + var z: Proxy ; // ok + + + interface Blah { + foo: number; + } + + var u: Proxy; // ok \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.js b/tests/baselines/reference/nonPrimitiveInGeneric.js index c2e19dde1e4..b7080e149b4 100644 --- a/tests/baselines/reference/nonPrimitiveInGeneric.js +++ b/tests/baselines/reference/nonPrimitiveInGeneric.js @@ -21,6 +21,19 @@ bound2<{}>(); bound2(); bound2(); // expect error bound2(); // expect error + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // ok +var z: Proxy ; // ok + + +interface Blah { + foo: number; +} + +var u: Proxy; // ok //// [nonPrimitiveInGeneric.js] @@ -41,3 +54,7 @@ bound2(); bound2(); bound2(); // expect error bound2(); // expect error +var x; // error +var y; // ok +var z; // ok +var u; // ok diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt index cf09994888b..de6fbfcf698 100644 --- a/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt +++ b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt @@ -21,9 +21,12 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(41,5): erro tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,5): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,7): error TS2339: Property 'toString' does not exist on type 'never'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(52,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(53,14): error TS2344: Type 'null' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(54,14): error TS2344: Type 'undefined' does not satisfy the constraint 'object'. -==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (19 errors) ==== +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (22 errors) ==== var a: object declare var b: object | null @@ -114,4 +117,22 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): erro ~ !!! error TS2531: Object is possibly 'null'. } + + interface Proxy {} + + var x: Proxy; // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + var y: Proxy; // error + ~~~~ +!!! error TS2344: Type 'null' does not satisfy the constraint 'object'. + var z: Proxy; // error + ~~~~~~~~~ +!!! error TS2344: Type 'undefined' does not satisfy the constraint 'object'. + + interface Blah { + foo: number; + } + + var u: Proxy; // ok \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.js b/tests/baselines/reference/nonPrimitiveStrictNull.js index c91097de960..754ca8cac7d 100644 --- a/tests/baselines/reference/nonPrimitiveStrictNull.js +++ b/tests/baselines/reference/nonPrimitiveStrictNull.js @@ -47,6 +47,18 @@ if (typeof d === 'undefined') { } else { d.toString(); // error, object | null } + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // error +var z: Proxy; // error + +interface Blah { + foo: number; +} + +var u: Proxy; // ok //// [nonPrimitiveStrictNull.js] @@ -91,3 +103,7 @@ if (typeof d === 'undefined') { else { d.toString(); // error, object | null } +var x; // error +var y; // error +var z; // error +var u; // ok diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts index 0de4771a5ef..a19271a59d3 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts @@ -20,3 +20,16 @@ bound2<{}>(); bound2(); bound2(); // expect error bound2(); // expect error + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // ok +var z: Proxy ; // ok + + +interface Blah { + foo: number; +} + +var u: Proxy; // ok diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts index 78f2d5ff7ba..3c2b9646c7e 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts @@ -47,3 +47,15 @@ if (typeof d === 'undefined') { } else { d.toString(); // error, object | null } + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // error +var z: Proxy; // error + +interface Blah { + foo: number; +} + +var u: Proxy; // ok From 8b411effa637c5cd345471da485fa4c37868aec3 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Fri, 16 Dec 2016 10:26:49 +0800 Subject: [PATCH 036/175] address CR feedback --- .../reference/nonPrimitiveAssignError.errors.txt | 14 ++++++++------ .../baselines/reference/nonPrimitiveAssignError.js | 4 ++++ ...rrors.txt => nonPrimitiveInFunction.errors.txt} | 8 ++++---- ...tiveInFunction.js => nonPrimitiveInFunction.js} | 4 ++-- .../types/nonPrimitive/nonPrimitiveAssignError.ts | 2 ++ ...tiveInFunction.ts => nonPrimitiveInFunction.ts} | 0 6 files changed, 20 insertions(+), 12 deletions(-) rename tests/baselines/reference/{nonPriimitiveInFunction.errors.txt => nonPrimitiveInFunction.errors.txt} (56%) rename tests/baselines/reference/{nonPriimitiveInFunction.js => nonPrimitiveInFunction.js} (88%) rename tests/cases/conformance/types/nonPrimitive/{nonPriimitiveInFunction.ts => nonPrimitiveInFunction.ts} (100%) diff --git a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt index 093445570fe..bb62d494d74 100644 --- a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt +++ b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(5,1): error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. Property 'foo' is missing in type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(11,1): error TS2322: Type 'number' is not assignable to type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(12,1): error TS2322: Type 'true' is not assignable to type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(13,1): error TS2322: Type 'string' is not assignable to type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(15,1): error TS2322: Type 'object' is not assignable to type 'number'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(16,1): error TS2322: Type 'object' is not assignable to type 'boolean'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): error TS2322: Type 'object' is not assignable to type 'string'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(13,1): error TS2322: Type 'number' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(14,1): error TS2322: Type 'true' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(15,1): error TS2322: Type 'string' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): error TS2322: Type 'object' is not assignable to type 'number'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(18,1): error TS2322: Type 'object' is not assignable to type 'boolean'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(19,1): error TS2322: Type 'object' is not assignable to type 'string'. ==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts (7 errors) ==== @@ -17,6 +17,8 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): err ~ !!! error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. !!! error TS2322: Property 'foo' is missing in type 'object'. + a = x; + a = y; var n = 123; var b = true; diff --git a/tests/baselines/reference/nonPrimitiveAssignError.js b/tests/baselines/reference/nonPrimitiveAssignError.js index e7bb56746ca..c37836a91c6 100644 --- a/tests/baselines/reference/nonPrimitiveAssignError.js +++ b/tests/baselines/reference/nonPrimitiveAssignError.js @@ -4,6 +4,8 @@ var y = {foo: "bar"}; var a: object; x = a; y = a; // expect error +a = x; +a = y; var n = 123; var b = true; @@ -32,6 +34,8 @@ var y = { foo: "bar" }; var a; x = a; y = a; // expect error +a = x; +a = y; var n = 123; var b = true; var s = "fooo"; diff --git a/tests/baselines/reference/nonPriimitiveInFunction.errors.txt b/tests/baselines/reference/nonPrimitiveInFunction.errors.txt similarity index 56% rename from tests/baselines/reference/nonPriimitiveInFunction.errors.txt rename to tests/baselines/reference/nonPrimitiveInFunction.errors.txt index 4b244cfcd04..5ca231b61c8 100644 --- a/tests/baselines/reference/nonPriimitiveInFunction.errors.txt +++ b/tests/baselines/reference/nonPrimitiveInFunction.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts(12,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts(13,1): error TS2322: Type 'object' is not assignable to type 'boolean'. -tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts(17,12): error TS2322: Type 'number' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(12,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(13,1): error TS2322: Type 'object' is not assignable to type 'boolean'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(17,12): error TS2322: Type 'number' is not assignable to type 'object'. -==== tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts (3 errors) ==== +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts (3 errors) ==== function takeObject(o: object) {} function returnObject(): object { return {}; diff --git a/tests/baselines/reference/nonPriimitiveInFunction.js b/tests/baselines/reference/nonPrimitiveInFunction.js similarity index 88% rename from tests/baselines/reference/nonPriimitiveInFunction.js rename to tests/baselines/reference/nonPrimitiveInFunction.js index a534ea7c84e..a67b68542dd 100644 --- a/tests/baselines/reference/nonPriimitiveInFunction.js +++ b/tests/baselines/reference/nonPrimitiveInFunction.js @@ -1,4 +1,4 @@ -//// [nonPriimitiveInFunction.ts] +//// [nonPrimitiveInFunction.ts] function takeObject(o: object) {} function returnObject(): object { return {}; @@ -19,7 +19,7 @@ function returnError(): object { } -//// [nonPriimitiveInFunction.js] +//// [nonPrimitiveInFunction.js] function takeObject(o) { } function returnObject() { return {}; diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts index 8fe8c8a3ebb..83801652865 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts @@ -3,6 +3,8 @@ var y = {foo: "bar"}; var a: object; x = a; y = a; // expect error +a = x; +a = y; var n = 123; var b = true; diff --git a/tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts similarity index 100% rename from tests/cases/conformance/types/nonPrimitive/nonPriimitiveInFunction.ts rename to tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts From 66069fc382ca71e703c9a953db7215151490b6c5 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Mon, 19 Dec 2016 13:36:49 +0800 Subject: [PATCH 037/175] update implementation to use intrinsic type --- src/compiler/checker.ts | 20 ++++++++----------- src/compiler/types.ts | 7 ++++--- .../nonPrimitiveAssignError.errors.txt | 4 ++-- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a1fae5ebbd3..b7d8ccf7f16 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -144,9 +144,9 @@ namespace ts { const voidType = createIntrinsicType(TypeFlags.Void, "void"); const neverType = createIntrinsicType(TypeFlags.Never, "never"); const silentNeverType = createIntrinsicType(TypeFlags.Never, "never"); + const nonPrimitiveType = createIntrinsicType(TypeFlags.NonPrimitive, "object"); const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - const nonPrimitiveType = createNonPrimitiveType(); const emptyTypeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral | SymbolFlags.Transient, "__type"); emptyTypeLiteralSymbol.members = createMap(); @@ -1685,13 +1685,6 @@ namespace ts { return type; } - function createNonPrimitiveType(): ResolvedType { - const type = setStructuredTypeMembers( - createObjectType(ObjectFlags.NonPrimitive, undefined), - emptySymbols, emptyArray, emptyArray, undefined, undefined); - return type; - } - function createObjectType(objectFlags: ObjectFlags, symbol?: Symbol): ObjectType { const type = createType(TypeFlags.Object); type.objectFlags = objectFlags; @@ -2320,9 +2313,6 @@ namespace ts { else if (type.flags & TypeFlags.UnionOrIntersection) { writeUnionOrIntersectionType(type, nextFlags); } - else if (getObjectFlags(type) & ObjectFlags.NonPrimitive) { - writer.writeKeyword("object"); - } else if (getObjectFlags(type) & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { writeAnonymousType(type, nextFlags); } @@ -4771,6 +4761,7 @@ namespace ts { t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType() : + t.flags & TypeFlags.NonPrimitive ? globalObjectType : t; } @@ -7153,6 +7144,8 @@ namespace ts { if (source.flags & TypeFlags.Enum && target.flags & TypeFlags.Enum && isEnumTypeRelatedTo(source, target, errorReporter)) return true; if (source.flags & TypeFlags.Undefined && (!strictNullChecks || target.flags & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true; + if (source.flags & TypeFlags.Object && target === nonPrimitiveType) return true; + if (source.flags & TypeFlags.Primitive && target === nonPrimitiveType) return false; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & TypeFlags.Any) return true; if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true; @@ -7471,7 +7464,7 @@ namespace ts { } } } - else if (!(source.flags & TypeFlags.Primitive && target === nonPrimitiveType)) { + else { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if relationship holds for all type arguments if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { @@ -9224,6 +9217,9 @@ namespace ts { } function getTypeFacts(type: Type): TypeFacts { + if (type === nonPrimitiveType) { + return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; + } const flags = type.flags; if (flags & TypeFlags.String) { return strictNullChecks ? TypeFacts.StringStrictFacts : TypeFacts.StringFacts; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index db919b56449..5b411ffea30 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2781,6 +2781,7 @@ namespace ts { ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type /* @internal */ ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type + NonPrimitive = 1 << 24, // intrinsic object type /* @internal */ Nullable = Undefined | Null, @@ -2790,7 +2791,7 @@ namespace ts { DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean, /* @internal */ - Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never, + Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive, /* @internal */ Primitive = String | Number | Boolean | Enum | ESSymbol | Void | Undefined | Null | Literal, StringLike = String | StringLiteral | Index, @@ -2798,14 +2799,14 @@ namespace ts { BooleanLike = Boolean | BooleanLiteral, EnumLike = Enum | EnumLiteral, UnionOrIntersection = Union | Intersection, - StructuredType = Object | Union | Intersection, + StructuredType = Object | Union | Intersection | NonPrimitive, StructuredOrTypeParameter = StructuredType | TypeParameter | Index, TypeVariable = TypeParameter | IndexedAccess, // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol, - NotUnionOrUnit = Any | ESSymbol | Object, + NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ diff --git a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt index bb62d494d74..a9bfaaa4a8a 100644 --- a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt +++ b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(5,1): error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. - Property 'foo' is missing in type 'object'. + Property 'foo' is missing in type 'Object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(13,1): error TS2322: Type 'number' is not assignable to type 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(14,1): error TS2322: Type 'true' is not assignable to type 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(15,1): error TS2322: Type 'string' is not assignable to type 'object'. @@ -16,7 +16,7 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(19,1): err y = a; // expect error ~ !!! error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. -!!! error TS2322: Property 'foo' is missing in type 'object'. +!!! error TS2322: Property 'foo' is missing in type 'Object'. a = x; a = y; From 899387706fb11d48c6b6a5f4f986d6723a3026f3 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Thu, 22 Dec 2016 10:02:26 +0800 Subject: [PATCH 038/175] classify nonPrimitive type as narrowable rather than structured --- src/compiler/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5b411ffea30..03cbd252924 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2799,13 +2799,13 @@ namespace ts { BooleanLike = Boolean | BooleanLiteral, EnumLike = Enum | EnumLiteral, UnionOrIntersection = Union | Intersection, - StructuredType = Object | Union | Intersection | NonPrimitive, + StructuredType = Object | Union | Intersection, StructuredOrTypeParameter = StructuredType | TypeParameter | Index, TypeVariable = TypeParameter | IndexedAccess, // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol, + Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | NonPrimitive, NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, From 8386d491abacdf2f43aacace0efcaa37b27b748d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 27 Dec 2016 11:17:33 -0800 Subject: [PATCH 039/175] Use sparse arrays for number-keyed maps --- src/compiler/checker.ts | 9 +- src/compiler/core.ts | 36 +++--- src/compiler/factory.ts | 30 ++--- src/compiler/sourcemap.ts | 2 +- src/compiler/transformer.ts | 22 ++-- src/compiler/transformers/generators.ts | 28 ++--- src/compiler/transformers/module/module.ts | 55 ++++----- src/compiler/transformers/module/system.ts | 53 +++++---- src/compiler/transformers/ts.ts | 14 +-- src/compiler/tsc.ts | 16 +-- src/compiler/types.ts | 22 ++-- src/compiler/utilities.ts | 6 +- src/compiler/visitor.ts | 104 +++++++++--------- src/harness/unittests/session.ts | 10 +- .../unittests/tsserverProjectSystem.ts | 22 ++-- src/services/codefixes/codeFixProvider.ts | 10 +- src/services/codefixes/importFixes.ts | 22 ++-- 17 files changed, 240 insertions(+), 221 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2394d5017a3..47a7db16986 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4054,16 +4054,15 @@ namespace ts { enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { const memberTypeList: Type[] = []; - const memberTypes = createMap(); + const memberTypes = sparseArray(); for (const declaration of enumType.symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { computeEnumMemberValues(declaration); for (const member of (declaration).members) { const memberSymbol = getSymbolOfNode(member); const value = getEnumMemberValue(member); - if (!memberTypes.has(value)) { - const memberType = createEnumLiteralType(memberSymbol, enumType, "" + value); - memberTypes.set(value, memberType); + if (!memberTypes[value]) { + const memberType = memberTypes[value] = createEnumLiteralType(memberSymbol, enumType, "" + value); memberTypeList.push(memberType); } } @@ -4085,7 +4084,7 @@ namespace ts { if (!links.declaredType) { const enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); links.declaredType = enumType.flags & TypeFlags.Union ? - enumType.memberTypes.get(getEnumMemberValue(symbol.valueDeclaration)) : + enumType.memberTypes[getEnumMemberValue(symbol.valueDeclaration)] : enumType; } return links.declaredType; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 6239dc93146..36847796b6e 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -39,6 +39,8 @@ namespace ts { return map; } + export const sparseArray: () => SparseArray = createMapLike; + /** Create a new map. If a template object is provided, the map will copy entries from it. */ export function createMap(template?: MapLike): Map { const map: Map = new MapCtr(); @@ -52,17 +54,6 @@ namespace ts { return map; } - /** Create a map from [key, value] pairs. This avoids casting keys to strings. */ - export function createMapFromPairs(...pairs: [number, T][]): Map { - const map: Map = new MapCtr(); - - for (const [key, value] of pairs) { - map.set(key, value); - } - - return map; - } - /** Methods on native maps but not on shim maps. Only used in this file. */ interface ES6Map extends Map { entries(): Iterator<[string, T]>; @@ -92,21 +83,21 @@ namespace ts { return class implements ShimMap { private data = createMapLike(); - get(key: MapKey): T { + get(key: string): T { return this.data[key]; } - set(key: MapKey, value: T): this { + set(key: string, value: T): this { this.data[key] = value; return this; } - has(key: MapKey): boolean { + has(key: string): boolean { // tslint:disable-next-line:no-in-operator return key in this.data; } - delete(key: MapKey): boolean { + delete(key: string): boolean { const had = this.has(key); if (had) { delete this.data[key]; @@ -890,7 +881,7 @@ namespace ts { * Array of every key in a map. * May not actually return string[] if numbers were put into the map. */ - export function keysOfMap(map: Map): string[] { + export function keysOfMap(map: Map<{}>): string[] { const keys: string[] = []; forEachKeyInMap(map, key => { keys.push(key); @@ -1040,7 +1031,7 @@ namespace ts { * Adds the value to an array of values associated with the key, and returns the array. * Creates the array if it does not already exist. */ - export function multiMapAdd(map: Map, key: string | number, value: V): V[] { + export function multiMapAdd(map: Map, key: string, value: V): V[] { let values = map.get(key); if (values) { values.push(value); @@ -1051,6 +1042,17 @@ namespace ts { return values; } + export function multiMapSparseArrayAdd(map: SparseArray, key: number, value: V): V[] { + let values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } + /** * Removes a value from an array of values associated with the key. * Does not preserve the order of those values. diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 2ef73dea727..15a946648b1 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -2641,9 +2641,11 @@ namespace ts { return destEmitNode; } - function mergeTokenSourceMapRanges(sourceRanges: Map, destRanges: Map) { - if (!destRanges) destRanges = createMap(); - copyMapEntries(sourceRanges, destRanges); + function mergeTokenSourceMapRanges(sourceRanges: SparseArray, destRanges: SparseArray) { + if (!destRanges) destRanges = []; + for (const key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } return destRanges; } @@ -2745,7 +2747,7 @@ namespace ts { export function getTokenSourceMapRange(node: Node, token: SyntaxKind) { const emitNode = node.emitNode; const tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges.get(token); + return tokenSourceMapRanges && tokenSourceMapRanges[token]; } /** @@ -2757,8 +2759,8 @@ namespace ts { */ export function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange) { const emitNode = getOrCreateEmitNode(node); - const tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = createMap()); - tokenSourceMapRanges.set(token, range); + const tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); + tokenSourceMapRanges[token] = range; return node; } @@ -3270,7 +3272,7 @@ namespace ts { externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers exportSpecifiers: Map; // export specifiers by name - exportedBindings: Map; // exported names of local declarations + exportedBindings: SparseArray; // exported names of local declarations exportedNames: Identifier[]; // all exported names local to module exportEquals: ExportAssignment | undefined; // an export= declaration if one was present hasExportStarsToExportValues: boolean; // whether this module contains export* @@ -3279,7 +3281,7 @@ namespace ts { export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; const exportSpecifiers = createMap(); - const exportedBindings = createMap(); + const exportedBindings = sparseArray(); const uniqueExports = createMap(); let exportedNames: Identifier[]; let hasExportDefault = false; @@ -3338,7 +3340,7 @@ namespace ts { || resolver.getReferencedValueDeclaration(name); if (decl) { - multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); } uniqueExports.set(specifier.name.text, true); @@ -3368,7 +3370,7 @@ namespace ts { if (hasModifier(node, ModifierFlags.Default)) { // export default function() { } if (!hasExportDefault) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } @@ -3376,7 +3378,7 @@ namespace ts { // export function x() { } const name = (node).name; if (!uniqueExports.get(name.text)) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), name); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); uniqueExports.set(name.text, true); exportedNames = append(exportedNames, name); } @@ -3389,7 +3391,7 @@ namespace ts { if (hasModifier(node, ModifierFlags.Default)) { // export default class { } if (!hasExportDefault) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } @@ -3397,7 +3399,7 @@ namespace ts { // export class x { } const name = (node).name; if (!uniqueExports.get(name.text)) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), name); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); uniqueExports.set(name.text, true); exportedNames = append(exportedNames, name); } diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index a814a91c355..650b9b0ef02 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -362,7 +362,7 @@ namespace ts { const emitNode = node && node.emitNode; const emitFlags = emitNode && emitNode.flags; - const range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges.get(token); + const range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; tokenPos = skipTrivia(currentSourceText, range ? range.pos : tokenPos); if ((emitFlags & EmitFlags.NoTokenLeadingSourceMaps) === 0 && tokenPos >= 0) { diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 1440481d38e..cef8c701455 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -13,14 +13,16 @@ /* @internal */ namespace ts { - const moduleTransformerMap = createMapFromPairs( - [ModuleKind.ES2015, transformES2015Module], - [ModuleKind.System, transformSystemModule], - [ModuleKind.AMD, transformModule], - [ModuleKind.CommonJS, transformModule], - [ModuleKind.UMD, transformModule], - [ModuleKind.None, transformModule], - ); + function getModuleTransformer(moduleKind: ModuleKind): Transformer { + switch (moduleKind) { + case ModuleKind.ES2015: + return transformES2015Module; + case ModuleKind.System: + return transformSystemModule; + default: + return transformModule; + } + } const enum SyntaxKindFeatureFlags { Substitution = 1 << 0, @@ -56,7 +58,7 @@ namespace ts { transformers.push(transformGenerators); } - transformers.push(moduleTransformerMap.get(moduleKind) || moduleTransformerMap.get(ModuleKind.None)); + transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 0b853649e81..85aba96387b 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 @@ -217,13 +217,15 @@ namespace ts { Endfinally = 7, } - const instructionNames = createMapFromPairs( - [Instruction.Return, "return"], - [Instruction.Break, "break"], - [Instruction.Yield, "yield"], - [Instruction.YieldStar, "yield*"], - [Instruction.Endfinally, "endfinally"], - ); + function getInstructionName(instruction: Instruction): string { + switch (instruction) { + case Instruction.Return: return "return"; + case Instruction.Break: return "break"; + case Instruction.Yield: return "yield"; + case Instruction.YieldStar: return "yield*"; + case Instruction.Endfinally: return "endfinally"; + } + } export function transformGenerators(context: TransformationContext) { const { @@ -241,7 +243,7 @@ namespace ts { let currentSourceFile: SourceFile; let renamedCatchVariables: Map; - let renamedCatchVariableDeclarations: Map; + let renamedCatchVariableDeclarations: SparseArray; let inGeneratorFunctionBody: boolean; let inStatementContainingYield: boolean; @@ -1926,7 +1928,7 @@ namespace ts { if (isIdentifier(original) && original.parent) { const declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - const name = renamedCatchVariableDeclarations.get(getOriginalNodeId(declaration)); + const name = renamedCatchVariableDeclarations[getOriginalNodeId(declaration)]; if (name) { const clone = getMutableClone(name); setSourceMapRange(clone, node); @@ -2092,12 +2094,12 @@ namespace ts { if (!renamedCatchVariables) { renamedCatchVariables = createMap(); - renamedCatchVariableDeclarations = createMap(); + renamedCatchVariableDeclarations = sparseArray(); context.enableSubstitution(SyntaxKind.Identifier); } renamedCatchVariables.set(text, true); - renamedCatchVariableDeclarations.set(getOriginalNodeId(variable), name); + renamedCatchVariableDeclarations[getOriginalNodeId(variable)] = name; const exception = peekBlock(); Debug.assert(exception.state < ExceptionBlockState.Catch); @@ -2401,7 +2403,7 @@ namespace ts { */ function createInstruction(instruction: Instruction): NumericLiteral { const literal = createLiteral(instruction); - literal.trailingComment = instructionNames.get(instruction); + literal.trailingComment = getInstructionName(instruction); return literal; } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 5d05667e4c2..e5e27c8360d 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1,4 +1,4 @@ -/// +/// /// /*@internal*/ @@ -10,12 +10,13 @@ namespace ts { importAliasNames: ParameterDeclaration[]; } - const transformModuleDelegates = createMapFromPairs<(node: SourceFile) => SourceFile>( - [ModuleKind.None, transformCommonJSModule], - [ModuleKind.CommonJS, transformCommonJSModule], - [ModuleKind.AMD, transformAMDModule], - [ModuleKind.UMD, transformUMDModule], - ); + function getTransformModuleDelegate(moduleKind: ModuleKind): (node: SourceFile) => SourceFile { + switch (moduleKind) { + case ModuleKind.AMD: return transformAMDModule; + case ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } const { startLexicalEnvironment, @@ -38,12 +39,12 @@ namespace ts { context.enableSubstitution(SyntaxKind.ShorthandPropertyAssignment); // Substitutes shorthand property assignments for imported/exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap = createMap(); // The ExternalModuleInfo for each file. - const deferredExports = createMap(); // Exports to defer until an EndOfDeclarationMarker is found. + const moduleInfoMap = sparseArray(); // The ExternalModuleInfo for each file. + const deferredExports = sparseArray(); // Exports to defer until an EndOfDeclarationMarker is found. let currentSourceFile: SourceFile; // The current file. let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file. - let noSubstitution: Map; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: SparseArray; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; @@ -61,10 +62,10 @@ namespace ts { currentSourceFile = node; currentModuleInfo = collectExternalModuleInfo(node, resolver, compilerOptions); - moduleInfoMap.set(getOriginalNodeId(node), currentModuleInfo); + moduleInfoMap[getOriginalNodeId(node)] = currentModuleInfo; // Perform the transformation. - const transformModule = transformModuleDelegates.get(moduleKind) || transformModuleDelegates.get(ModuleKind.None); + const transformModule = getTransformModuleDelegate(moduleKind); const updated = transformModule(node); currentSourceFile = undefined; @@ -445,7 +446,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfImportDeclaration(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); } else { statements = appendExportsOfImportDeclaration(statements, node); @@ -524,7 +525,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfImportEqualsDeclaration(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); } else { statements = appendExportsOfImportEqualsDeclaration(statements, node); @@ -611,7 +612,7 @@ namespace ts { if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportStatement(deferredExports.get(id), createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true)); + deferredExports[id] = appendExportStatement(deferredExports[id], createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); } else { statements = appendExportStatement(statements, createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); @@ -652,7 +653,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfHoistedDeclaration(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); } else { statements = appendExportsOfHoistedDeclaration(statements, node); @@ -691,7 +692,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfHoistedDeclaration(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); } else { statements = appendExportsOfHoistedDeclaration(statements, node); @@ -742,7 +743,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfVariableStatement(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); } else { statements = appendExportsOfVariableStatement(statements, node); @@ -795,7 +796,7 @@ namespace ts { // statement. if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === SyntaxKind.VariableStatement) { const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfVariableStatement(deferredExports.get(id), node.original)); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; @@ -821,9 +822,9 @@ namespace ts { // end of the transformed declaration. We use this marker to emit any deferred exports // of the declaration. const id = getOriginalNodeId(node); - const statements = deferredExports.get(id); + const statements = deferredExports[id]; if (statements) { - deferredExports.delete(id); + delete deferredExports[id]; return append(statements, node); } @@ -1103,8 +1104,8 @@ namespace ts { function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { if (node.kind === SyntaxKind.SourceFile) { currentSourceFile = node; - currentModuleInfo = moduleInfoMap.get(getOriginalNodeId(currentSourceFile)); - noSubstitution = createMap(); + currentModuleInfo = moduleInfoMap[getOriginalNodeId(currentSourceFile)]; + noSubstitution = sparseArray(); previousOnEmitNode(emitContext, node, emitCallback); @@ -1129,7 +1130,7 @@ namespace ts { */ function onSubstituteNode(emitContext: EmitContext, node: Node) { node = previousOnSubstituteNode(emitContext, node); - if (node.id && noSubstitution.get(node.id)) { + if (node.id && noSubstitution[node.id]) { return node; } @@ -1255,7 +1256,7 @@ namespace ts { let expression: Expression = node; for (const exportName of exportedNames) { // Mark the node to prevent triggering this rule again. - noSubstitution.set(getNodeId(expression), true); + noSubstitution[getNodeId(expression)] = true; expression = createExportExpression(exportName, expression, /*location*/ node); } @@ -1297,7 +1298,7 @@ namespace ts { : node; for (const exportName of exportedNames) { // Mark the node to prevent triggering this rule again. - noSubstitution.set(getNodeId(expression), true); + noSubstitution[getNodeId(expression)] = true; expression = createExportExpression(exportName, expression); } @@ -1319,7 +1320,7 @@ namespace ts { || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { return currentModuleInfo - && currentModuleInfo.exportedBindings.get(getOriginalNodeId(valueDeclaration)); + && currentModuleInfo.exportedBindings[getOriginalNodeId(valueDeclaration)]; } } } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index bc613bcfaf6..c20e6b5cf32 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1,4 +1,4 @@ -/// +/// /// /*@internal*/ @@ -28,10 +28,10 @@ namespace ts { context.enableSubstitution(SyntaxKind.PostfixUnaryExpression); // Substitutes updates to exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap = createMap(); // The ExternalModuleInfo for each file. - const deferredExports = createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - const exportFunctionsMap = createMap(); // The export function associated with a source file. - const noSubstitutionMap = createMap>(); // Set of nodes for which substitution rules should be ignored for each file. + const moduleInfoMap = sparseArray(); // The ExternalModuleInfo for each file. + const deferredExports = sparseArray(); // Exports to defer until an EndOfDeclarationMarker is found. + const exportFunctionsMap = sparseArray(); // The export function associated with a source file. + const noSubstitutionMap = sparseArray>(); // Set of nodes for which substitution rules should be ignored for each file. let currentSourceFile: SourceFile; // The current file. let moduleInfo: ExternalModuleInfo; // ExternalModuleInfo for the current file. @@ -39,7 +39,7 @@ namespace ts { let contextObject: Identifier; // The context object for the current file. let hoistedStatements: Statement[]; let enclosingBlockScopedContainer: Node; - let noSubstitution: Map; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: SparseArray; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; @@ -73,13 +73,12 @@ namespace ts { // see comment to 'substitutePostfixUnaryExpression' for more details // Collect information about the external module and dependency groups. - moduleInfo = collectExternalModuleInfo(node, resolver, compilerOptions); - moduleInfoMap.set(id, moduleInfo); + moduleInfo = moduleInfoMap[id] = collectExternalModuleInfo(node, resolver, compilerOptions); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. exportFunction = createUniqueName("exports"); - exportFunctionsMap.set(id, exportFunction); + exportFunctionsMap[id] = exportFunction; contextObject = createUniqueName("context"); // Add the body of the module. @@ -123,7 +122,7 @@ namespace ts { } if (noSubstitution) { - noSubstitutionMap.set(id, noSubstitution); + noSubstitutionMap[id] = noSubstitution; noSubstitution = undefined; } @@ -610,7 +609,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfImportDeclaration(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); } else { statements = appendExportsOfImportDeclaration(statements, node); @@ -633,7 +632,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfImportEqualsDeclaration(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); } else { statements = appendExportsOfImportEqualsDeclaration(statements, node); @@ -658,7 +657,7 @@ namespace ts { if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportStatement(deferredExports.get(id), createIdentifier("default"), expression, /*allowComments*/ true)); + deferredExports[id] = appendExportStatement(deferredExports[id], createIdentifier("default"), expression, /*allowComments*/ true); } else { return createExportStatement(createIdentifier("default"), expression, /*allowComments*/ true); @@ -690,7 +689,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfHoistedDeclaration(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); } else { hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node); @@ -732,7 +731,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfHoistedDeclaration(deferredExports.get(id), node)); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); } else { statements = appendExportsOfHoistedDeclaration(statements, node); @@ -772,7 +771,7 @@ namespace ts { if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node const id = getOriginalNodeId(node); - deferredExports.set(id, appendExportsOfVariableStatement(deferredExports.get(id), node, isExportedDeclaration)); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration); } else { statements = appendExportsOfVariableStatement(statements, node, /*exportSelf*/ false); @@ -885,7 +884,7 @@ namespace ts { if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === SyntaxKind.VariableStatement) { const id = getOriginalNodeId(node); const isExportedDeclaration = hasModifier(node.original, ModifierFlags.Export); - deferredExports.set(id, appendExportsOfVariableStatement(deferredExports.get(id), node.original, isExportedDeclaration)); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -911,9 +910,9 @@ namespace ts { // end of the transformed declaration. We use this marker to emit any deferred exports // of the declaration. const id = getOriginalNodeId(node); - const statements = deferredExports.get(id); + const statements = deferredExports[id]; if (statements) { - deferredExports.delete(id); + delete deferredExports[id]; return append(statements, node); } @@ -1556,12 +1555,12 @@ namespace ts { if (node.kind === SyntaxKind.SourceFile) { const id = getOriginalNodeId(node); currentSourceFile = node; - moduleInfo = moduleInfoMap.get(id); - exportFunction = exportFunctionsMap.get(id); - noSubstitution = noSubstitutionMap.get(id); + moduleInfo = moduleInfoMap[id]; + exportFunction = exportFunctionsMap[id]; + noSubstitution = noSubstitutionMap[id]; if (noSubstitution) { - noSubstitutionMap.delete(id); + delete noSubstitutionMap[id]; } previousOnEmitNode(emitContext, node, emitCallback); @@ -1758,7 +1757,7 @@ namespace ts { exportedNames = append(exportedNames, getDeclarationName(valueDeclaration)); } - exportedNames = addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings.get(getOriginalNodeId(valueDeclaration))); + exportedNames = addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[getOriginalNodeId(valueDeclaration)]); } } @@ -1771,8 +1770,8 @@ namespace ts { * @param node The node which should not be substituted. */ function preventSubstitution(node: T): T { - if (noSubstitution === undefined) noSubstitution = createMap(); - noSubstitution.set(getNodeId(node), true); + if (noSubstitution === undefined) noSubstitution = sparseArray(); + noSubstitution[getNodeId(node)] = true; return node; } @@ -1782,7 +1781,7 @@ namespace ts { * @param node The node to test. */ function isSubstitutionPrevented(node: Node) { - return noSubstitution && node.id && noSubstitution.get(node.id); + return noSubstitution && node.id && noSubstitution[node.id]; } } } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 4b0f981f27c..ef7001f3735 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1,4 +1,4 @@ -/// +/// /// /// @@ -60,7 +60,7 @@ namespace ts { * A map that keeps track of aliases created for classes with decorators to avoid issues * with the double-binding behavior of classes. */ - let classAliases: Map; + let classAliases: SparseArray; /** * Keeps track of whether we are within any containing namespaces when performing @@ -752,7 +752,7 @@ namespace ts { if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ClassWithConstructorReference) { // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); - classAliases.set(getOriginalNodeId(node), getSynthesizedClone(temp)); + classAliases[getOriginalNodeId(node)] = getSynthesizedClone(temp); } // To preserve the behavior of the old emitter, we explicitly indent @@ -1420,7 +1420,7 @@ namespace ts { return undefined; } - const classAlias = classAliases && classAliases.get(getOriginalNodeId(node)); + const classAlias = classAliases && classAliases[getOriginalNodeId(node)]; const localName = getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); const decorate = createDecorateHelper(context, decoratorExpressions, localName); const expression = createAssignment(localName, classAlias ? createAssignment(classAlias, decorate) : decorate); @@ -3085,7 +3085,7 @@ namespace ts { if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ClassWithConstructorReference) { enableSubstitutionForClassAliases(); const classAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default"); - classAliases.set(getOriginalNodeId(node), classAlias); + classAliases[getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; } @@ -3117,7 +3117,7 @@ namespace ts { context.enableSubstitution(SyntaxKind.Identifier); // Keep track of class aliases. - classAliases = createMap(); + classAliases = sparseArray(); } } @@ -3230,7 +3230,7 @@ namespace ts { // constructor references in static property initializers. const declaration = resolver.getReferencedValueDeclaration(node); if (declaration) { - const classAlias = classAliases.get(declaration.id); + const classAlias = classAliases[declaration.id]; if (classAlias) { const clone = getSynthesizedClone(classAlias); setSourceMapRange(clone, node); diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 5de16a20fc2..ba5a0d8faea 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -67,11 +67,13 @@ namespace ts { const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; - const categoryFormatMap = createMapFromPairs( - [DiagnosticCategory.Warning, yellowForegroundEscapeSequence], - [DiagnosticCategory.Error, redForegroundEscapeSequence], - [DiagnosticCategory.Message, blueForegroundEscapeSequence], - ); + function getCategoryFormat(category: DiagnosticCategory): string { + switch (category) { + case DiagnosticCategory.Warning: return yellowForegroundEscapeSequence; + case DiagnosticCategory.Error: return redForegroundEscapeSequence; + case DiagnosticCategory.Message: return blueForegroundEscapeSequence; + } + } function formatAndReset(text: string, formatStyle: string) { return formatStyle + text + resetEscapeSequence; @@ -139,7 +141,7 @@ namespace ts { output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } - const categoryColor = categoryFormatMap.get(diagnostic.category); + const categoryColor = getCategoryFormat(diagnostic.category); const category = DiagnosticCategory[diagnostic.category].toLowerCase(); output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; output += sys.newLine + sys.newLine; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b98a5a493ba..75ff806d605 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, @@ -8,15 +8,19 @@ namespace ts { [index: string]: T; } - /** It's allowed to get/set into a map with numbers. However, when iterating, you may get strings back due to the shim being an ordinary object (which only allows string keys). */ - export type MapKey = string | number; + /** + * Like MapLike, but keys must be numbers. + */ + export interface SparseArray { + [key: number]: T; + } /** Minimal ES6 Map interface. Does not include iterators as those are hard to shim performantly. */ export interface Map { - get(key: MapKey): T; - has(key: MapKey): boolean; - set(key: MapKey, value: T): this; - delete(key: MapKey): boolean; + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; clear(): void; /** `key` may *not* be a string if it was set with a number and we are not using the shim. */ forEach(action: (value: T, key: string) => void): void; @@ -2853,7 +2857,7 @@ namespace ts { // Enum types (TypeFlags.Enum) export interface EnumType extends Type { - memberTypes: Map; + memberTypes: SparseArray; } // Enum types (TypeFlags.EnumLiteral) @@ -3682,7 +3686,7 @@ namespace ts { flags?: EmitFlags; // Flags that customize emit commentRange?: TextRange; // The text range to use when emitting leading or trailing comments sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings - tokenSourceMapRanges?: Map; // The text range to use when emitting source mappings for tokens + tokenSourceMapRanges?: SparseArray; // The text range to use when emitting source mappings for tokens constantValue?: number; // The constant value of an expression externalHelpersModuleName?: Identifier; // The local name for an imported helpers module helpers?: EmitHelper[]; // Emit helpers for the node diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 25973cae5cb..ead1a3b62de 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3311,12 +3311,12 @@ namespace ts { return false; } - const syntaxKindCache = createMap(); + const syntaxKindCache = sparseArray(); export function formatSyntaxKind(kind: SyntaxKind): string { const syntaxKindEnum = (ts).SyntaxKind; if (syntaxKindEnum) { - const cached = syntaxKindCache.get(kind); + const cached = syntaxKindCache[kind]; if (cached !== undefined) { return cached; } @@ -3324,7 +3324,7 @@ namespace ts { for (const name in syntaxKindEnum) { if (syntaxKindEnum[name] === kind) { const result = `${kind} (${name})`; - syntaxKindCache.set(kind, result); + syntaxKindCache[kind] = result; return result; } } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index c9ea2af1a87..2afb1f8301e 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1,4 +1,4 @@ -/// +/// /// /// @@ -46,54 +46,56 @@ namespace ts { * supplant the existing `forEachChild` implementation if performance is not * significantly impacted. */ - const nodeEdgeTraversalMap = createMapFromPairs( - [SyntaxKind.QualifiedName, [ - { name: "left", test: isEntityName }, - { name: "right", test: isIdentifier } - ]], - [SyntaxKind.Decorator, [ - { name: "expression", test: isLeftHandSideExpression } - ]], - [SyntaxKind.TypeAssertionExpression, [ - { name: "type", test: isTypeNode }, - { name: "expression", test: isUnaryExpression } - ]], - [SyntaxKind.AsExpression, [ - { name: "expression", test: isExpression }, - { name: "type", test: isTypeNode } - ]], - [SyntaxKind.NonNullExpression, [ - { name: "expression", test: isLeftHandSideExpression } - ]], - [SyntaxKind.EnumDeclaration, [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isIdentifier }, - { name: "members", test: isEnumMember } - ]], - [SyntaxKind.ModuleDeclaration, [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isModuleName }, - { name: "body", test: isModuleBody } - ]], - [SyntaxKind.ModuleBlock, [ - { name: "statements", test: isStatement } - ]], - [SyntaxKind.ImportEqualsDeclaration, [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isIdentifier }, - { name: "moduleReference", test: isModuleReference } - ]], - [SyntaxKind.ExternalModuleReference, [ - { name: "expression", test: isExpression, optional: true } - ]], - [SyntaxKind.EnumMember, [ - { name: "name", test: isPropertyName }, - { name: "initializer", test: isExpression, optional: true, parenthesize: parenthesizeExpressionForList } - ]] - ); + function getNodeEdgeTraversal(kind: SyntaxKind): NodeTraversalPath { + switch (kind) { + case SyntaxKind.QualifiedName: return [ + { name: "left", test: isEntityName }, + { name: "right", test: isIdentifier } + ]; + case SyntaxKind.Decorator: return [ + { name: "expression", test: isLeftHandSideExpression } + ]; + case SyntaxKind.TypeAssertionExpression: return [ + { name: "type", test: isTypeNode }, + { name: "expression", test: isUnaryExpression } + ]; + case SyntaxKind.AsExpression: return [ + { name: "expression", test: isExpression }, + { name: "type", test: isTypeNode } + ]; + case SyntaxKind.NonNullExpression: return [ + { name: "expression", test: isLeftHandSideExpression } + ]; + case SyntaxKind.EnumDeclaration: return [ + { name: "decorators", test: isDecorator }, + { name: "modifiers", test: isModifier }, + { name: "name", test: isIdentifier }, + { name: "members", test: isEnumMember } + ]; + case SyntaxKind.ModuleDeclaration: return [ + { name: "decorators", test: isDecorator }, + { name: "modifiers", test: isModifier }, + { name: "name", test: isModuleName }, + { name: "body", test: isModuleBody } + ]; + case SyntaxKind.ModuleBlock: return [ + { name: "statements", test: isStatement } + ]; + case SyntaxKind.ImportEqualsDeclaration: return [ + { name: "decorators", test: isDecorator }, + { name: "modifiers", test: isModifier }, + { name: "name", test: isIdentifier }, + { name: "moduleReference", test: isModuleReference } + ]; + case SyntaxKind.ExternalModuleReference: return [ + { name: "expression", test: isExpression, optional: true } + ]; + case SyntaxKind.EnumMember: return [ + { name: "name", test: isPropertyName }, + { name: "initializer", test: isExpression, optional: true, parenthesize: parenthesizeExpressionForList } + ]; + } + } function reduceNode(node: Node, f: (memo: T, node: Node) => T, initial: T) { return node ? f(initial, node) : initial; @@ -530,7 +532,7 @@ namespace ts { break; default: - const edgeTraversalPath = nodeEdgeTraversalMap.get(kind); + const edgeTraversalPath = getNodeEdgeTraversal(kind); if (edgeTraversalPath) { for (const edge of edgeTraversalPath) { const value = (>node)[edge.name]; @@ -1188,7 +1190,7 @@ namespace ts { default: let updated: Node & MapLike; - const edgeTraversalPath = nodeEdgeTraversalMap.get(kind); + const edgeTraversalPath = getNodeEdgeTraversal(kind); if (edgeTraversalPath) { for (const edge of edgeTraversalPath) { const value = >(>node)[edge.name]; diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index da24fe1606b..70cda27747b 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -1,4 +1,4 @@ -/// +/// const expect: typeof _chai.expect = _chai.expect; @@ -416,16 +416,16 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks = createMap<(resp: protocol.Response) => void>(); + private callbacks = sparseArray<(resp: protocol.Response) => void>(); private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { if (msg.type === "response") { const response = msg; - const handler = this.callbacks.get(response.request_seq); + const handler = this.callbacks[response.request_seq]; if (handler) { handler(response); - this.callbacks.delete(response.request_seq); + delete this.callbacks[response.request_seq]; } } else if (msg.type === "event") { @@ -460,7 +460,7 @@ namespace ts.server { command, arguments: args }); - this.callbacks.set(this.seq, callback); + this.callbacks[this.seq] = callback; } }; diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 5b4ba7d7223..ae213bd0a50 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.projectSystem { @@ -290,30 +290,34 @@ namespace ts.projectSystem { } export class Callbacks { - private map = createMap(); + private map = sparseArray(); private nextId = 1; register(cb: (...args: any[]) => void, args: any[]) { const timeoutId = this.nextId; this.nextId++; - this.map.set(timeoutId, cb.bind(undefined, ...args)); + this.map[timeoutId] = cb.bind(undefined, ...args); return timeoutId; } unregister(id: any) { if (typeof id === "number") { - this.map.delete(id); + delete this.map[id]; } } count() { - return this.map.size; + let n = 0; + for (const _ in this.map) { + n++; + } + return n; } invoke() { - this.map.forEach(cb => { - cb(); - }); - this.map.clear(); + for (const key in this.map) { + this.map[key](); + } + this.map = sparseArray(); } } diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index c6373fc1909..fe3e71f1e1c 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -16,25 +16,25 @@ namespace ts { } export namespace codefix { - const codeFixes = createMap(); + const codeFixes = sparseArray(); export function registerCodeFix(action: CodeFix) { forEach(action.errorCodes, error => { - let fixes = codeFixes.get(error); + let fixes = codeFixes[error]; if (!fixes) { fixes = []; - codeFixes.set(error, fixes); + codeFixes[error] = fixes; } fixes.push(action); }); } export function getSupportedErrorCodes() { - return keysOfMap(codeFixes); + return keysOfSparseArray(codeFixes); } export function getFixes(context: CodeFixContext): CodeAction[] { - const fixes = codeFixes.get(context.errorCode); + const fixes = codeFixes[context.errorCode]; let allActions: CodeAction[] = []; forEach(fixes, f => { diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 0e7743e29fc..0df3c3134fe 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -14,16 +14,16 @@ namespace ts.codefix { } class ImportCodeActionMap { - private symbolIdToActionMap = createMap(); + private symbolIdToActionMap = sparseArray(); addAction(symbolId: number, newAction: ImportCodeAction) { if (!newAction) { return; } - const actions = this.symbolIdToActionMap.get(symbolId); + const actions = this.symbolIdToActionMap[symbolId]; if (!actions) { - this.symbolIdToActionMap.set(symbolId, [newAction]); + this.symbolIdToActionMap[symbolId] = [newAction]; return; } @@ -33,7 +33,7 @@ namespace ts.codefix { } const updatedNewImports: ImportCodeAction[] = []; - for (const existingAction of this.symbolIdToActionMap.get(symbolId)) { + for (const existingAction of this.symbolIdToActionMap[symbolId]) { if (existingAction.kind === "CodeChange") { // only import actions should compare updatedNewImports.push(existingAction); @@ -63,7 +63,7 @@ namespace ts.codefix { } // if we reach here, it means the new one is better or equal to all of the existing ones. updatedNewImports.push(newAction); - this.symbolIdToActionMap.set(symbolId, updatedNewImports); + this.symbolIdToActionMap[symbolId] = updatedNewImports; } addActions(symbolId: number, newActions: ImportCodeAction[]) { @@ -74,9 +74,9 @@ namespace ts.codefix { getAllActions() { let result: ImportCodeAction[] = []; - this.symbolIdToActionMap.forEach(actions => { - result = concatenate(result, actions); - }); + for (const key in this.symbolIdToActionMap) { + result = concatenate(result, this.symbolIdToActionMap[key]) + } return result; } @@ -125,7 +125,7 @@ namespace ts.codefix { const symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - const cachedImportDeclarations = createMap<(ImportDeclaration | ImportEqualsDeclaration)[]>(); + const cachedImportDeclarations = sparseArray<(ImportDeclaration | ImportEqualsDeclaration)[]>(); let cachedNewImportInsertPosition: number; const allPotentialModules = checker.getAmbientModules(); @@ -163,7 +163,7 @@ namespace ts.codefix { function getImportDeclarations(moduleSymbol: Symbol) { const moduleSymbolId = getUniqueSymbolId(moduleSymbol); - const cached = cachedImportDeclarations.get(moduleSymbolId); + const cached = cachedImportDeclarations[moduleSymbolId]; if (cached) { return cached; } @@ -175,7 +175,7 @@ namespace ts.codefix { existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); } } - cachedImportDeclarations.set(moduleSymbolId, existingDeclarations); + cachedImportDeclarations[moduleSymbolId] = existingDeclarations; return existingDeclarations; function getImportDeclaration(moduleSpecifier: LiteralExpression) { From 55552585d0f8b060e4794826d833229344fa0b2e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 27 Dec 2016 12:37:42 -0800 Subject: [PATCH 040/175] Add iterators to Map interface, and shim iterators --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 175 ++++++++++----------- src/compiler/transformers/module/system.ts | 2 +- src/compiler/types.ts | 11 +- src/services/codefixes/codeFixProvider.ts | 2 +- src/services/completions.ts | 2 +- 6 files changed, 100 insertions(+), 94 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 47a7db16986..4ecfdc4d2f4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6161,7 +6161,7 @@ namespace ts { if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers const aliasSymbol = getAliasSymbolForTypeNode(node); - if (mapIsEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 36847796b6e..a6766887494 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -54,40 +54,48 @@ namespace ts { return map; } - /** Methods on native maps but not on shim maps. Only used in this file. */ - interface ES6Map extends Map { - entries(): Iterator<[string, T]>; - } - - /** ES6 Iterator type. */ - interface Iterator { - next(): { value: T, done: false } | { value: never, done: true }; - } - - /** Shim maps support certain methods directly. For native maps we use a function. */ - interface ShimMap extends Map { - isEmpty(): boolean; - forEachInMap(callback: (value: T, key: string) => U | undefined): U | undefined; - some(predicate: (value: T, key: string) => boolean): boolean; - } - // The global Map object. This may not be available, so we must test for it. declare const Map: { new(): Map } | undefined; // Internet Explorer's Map doesn't support iteration, so don't use it. // tslint:disable-next-line:no-in-operator - const usingNativeMaps = typeof Map !== "undefined" && "entries" in Map.prototype; - const MapCtr = usingNativeMaps ? Map : shimMap(); + const MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap(): { new(): Map } { - return class implements ShimMap { + + class MapIterator { + private data: MapLike; + private keys: string[]; + private index = 0; + private selector: (data: MapLike, key: string) => U; + constructor(data: MapLike, selector: (data: MapLike, key: string) => U) { + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + + public next(): { value: U, done: false } | { value: never, done: true } { + const index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined as never, done: true } + } + } + + return class implements Map { private data = createMapLike(); + public size = 0; get(key: string): T { return this.data[key]; } set(key: string, value: T): this { + if (!this.has(key)) { + this.size++; + } this.data[key] = value; return this; } @@ -98,15 +106,29 @@ namespace ts { } delete(key: string): boolean { - const had = this.has(key); - if (had) { + if (this.has(key)) { + this.size--; delete this.data[key]; + return true; } - return had; + return false; } clear(): void { this.data = createMapLike(); + this.size = 0; + } + + keys() { + return new MapIterator(this.data, (_data, key) => key); + } + + values() { + return new MapIterator(this.data, (data, key) => data[key]); + } + + entries() { + return new MapIterator(this.data, (data, key) => [key, data[key]]); } forEach(action: (value: T, key: string) => void): void { @@ -114,36 +136,6 @@ namespace ts { action(this.data[key], key); } } - - isEmpty(): boolean { - return !this.some(() => true); - } - - get size(): number { - let size = 0; - for (const _ in this.data) { - size++; - } - return size; - } - - forEachInMap(callback: (value: T, key: string) => U | undefined): U | undefined { - for (const key in this.data) { - const result = callback(this.data[key], key); - if (result !== undefined) { - return result; - } - } - } - - some(predicate: (value: T, key: string) => boolean): boolean { - for (const key in this.data) { - if (predicate(this.data[key], key)) { - return true; - } - } - return false; - } } } @@ -877,65 +869,76 @@ namespace ts { return keys; } + function arrayFrom(iterator: Iterator): T[] { + const result: T[] = []; + for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) { + result.push(value); + } + return result; + } + /** * Array of every key in a map. * May not actually return string[] if numbers were put into the map. */ export function keysOfMap(map: Map<{}>): string[] { - const keys: string[] = []; - forEachKeyInMap(map, key => { - keys.push(key); - }); - return keys; + return arrayFrom(map.keys()); } /** Array of every value in a map. */ export function valuesOfMap(map: Map): T[] { - const values: T[] = []; - map.forEach(value => { - values.push(value); - }); - return values; + return arrayFrom(map.values()); } /** * Calls `callback` for each entry in the map, returning the first defined result. * Use `map.forEach` instead for normal iteration. */ - export const forEachInMap: (map: Map, callback: (value: T, key: string) => U | undefined) => U | undefined = usingNativeMaps - ? (map: ES6Map, callback: (value: T, key: string) => U | undefined) => { - const iterator = map.entries(); - while (true) { - const { value: pair, done } = iterator.next(); - if (done) return undefined; - const [key, value] = pair; - const result = callback(value, key); - if (result !== undefined) return result; + export function forEachInMap(map: Map, callback: (value: T, key: string) => U | undefined): U | undefined { + const iterator = map.entries(); + for (let { value: pair, done } = iterator.next(); !done; { value: pair, done } = iterator.next()) { + const [key, value] = pair; + const result = callback(value, key); + if (result !== undefined) { + return result; } } - : (map: ShimMap, callback: (value: T, key: string) => U | undefined) => map.forEachInMap(callback); + return undefined; + } /** `forEachInMap` for just keys. */ export function forEachKeyInMap(map: Map<{}>, callback: (key: string) => T | undefined): T | undefined { - return forEachInMap(map, (_, key) => callback(key)); + const iterator = map.keys(); + for (let { value: key, done } = iterator.next(); !done; { value: key, done } = iterator.next()) { + const result = callback(key); + if (result !== undefined) { + return result; + } + } + return undefined; } /** Whether `predicate` is true for some entry in the map. */ - export const someInMap: (map: Map, predicate: (value: T, key: string) => boolean) => boolean = usingNativeMaps - ? (map: ES6Map, predicate: (value: T, key: string) => boolean) => { - const iterator = map.entries(); - while (true) { - const { value: pair, done } = iterator.next(); - if (done) return false; - const [key, value] = pair; - if (predicate(value, key)) return true; + export function someInMap(map: Map, predicate: (value: T, key: string) => boolean): boolean { + const iterator = map.entries(); + for (let { value: pair, done } = iterator.next(); !done; { value: pair, done } = iterator.next()) { + const [key, value] = pair; + if (predicate(value, key)) { + return true; } } - : (map: ShimMap, predicate: (value: T, key: string) => boolean) => map.some(predicate); + return false; + } /** `someInMap` for just keys. */ export function someKeyInMap(map: Map<{}>, predicate: (key: string) => boolean): boolean { - return someInMap(map, (_, key) => predicate(key)); + const iterator = map.keys(); + for (let { value: key, done } = iterator.next(); !done; { value: key, done } = iterator.next()) { + if (predicate(key)) { + return true; + } + } + return false; } /** Copy entries from `source` to `target`. */ @@ -996,10 +999,6 @@ namespace ts { return result; } - export const mapIsEmpty: (map: Map<{}>) => boolean = usingNativeMaps - ? (map: ES6Map<{}>) => map.size === 0 - : (map: ShimMap<{}>) => map.isEmpty(); - export function cloneMap(map: Map) { const clone = createMap(); copyMapEntries(map, clone); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index c20e6b5cf32..28179969ba2 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -306,7 +306,7 @@ namespace ts { // this set is used to filter names brought by star expors. // local names set should only be added if we have anything exported - if (!moduleInfo.exportedNames && mapIsEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. let hasExportDeclarationWithExportClause = false; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 75ff806d605..a842dbb093d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -15,16 +15,23 @@ [key: number]: T; } - /** Minimal ES6 Map interface. Does not include iterators as those are hard to shim performantly. */ + /** ES6 Map interface. */ export interface Map { get(key: string): T; has(key: string): boolean; set(key: string, value: T): this; delete(key: string): boolean; clear(): void; - /** `key` may *not* be a string if it was set with a number and we are not using the shim. */ forEach(action: (value: T, key: string) => void): void; readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + + /** ES6 Iterator type. */ + export interface Iterator { + next(): { value: T, done: false } | { value: never, done: true }; } // branded string type used to store absolute, normalized and canonicalized paths diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index fe3e71f1e1c..f4cb411b064 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -30,7 +30,7 @@ namespace ts { } export function getSupportedErrorCodes() { - return keysOfSparseArray(codeFixes); + return Object.keys(codeFixes); } export function getFixes(context: CodeFixContext): CodeAction[] { diff --git a/src/services/completions.ts b/src/services/completions.ts index f7efe1fec56..4715222db08 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1566,7 +1566,7 @@ namespace ts.Completions { existingImportsOrExports.set(name.text, true); } - if (mapIsEmpty(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return filter(exportsOfModule, e => e.name !== "default"); } From 3d7b5e6019b73e062dcd01fb6376a7087cf61a12 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 27 Dec 2016 12:46:28 -0800 Subject: [PATCH 041/175] Make `createMapLike` private and rename to `createDictionaryObject` --- src/compiler/commandLineParser.ts | 6 +++--- src/compiler/core.ts | 10 +++++----- src/harness/harnessLanguageService.ts | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b3c538afd0a..4708b842763 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -762,7 +762,7 @@ namespace ts { } function serializeCompilerOptions(options: CompilerOptions): MapLike { - const result = createMapLike(); + const result: ts.MapLike = {}; const optionsNameMap = getOptionNameMap().optionNameMap; for (const name in options) { @@ -1302,7 +1302,7 @@ namespace ts { // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude"); const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - const wildcardDirectories = createMapLike(); + const wildcardDirectories: ts.MapLike = {}; if (include !== undefined) { const recursiveKeys: string[] = []; for (const file of include) { @@ -1325,7 +1325,7 @@ namespace ts { } // Remove any subpaths under an existing recursively watched directory. - for (const key in wildcardDirectories) { + for (const key in wildcardDirectories) if (hasProperty(wildcardDirectories, key)) { for (const recursiveKey of recursiveKeys) { if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { delete wildcardDirectories[key]; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index a6766887494..693f6673234 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -26,8 +26,8 @@ namespace ts { // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - /** Create a MapLike with good performance. Prefer this over a literal `{}`. */ - export function createMapLike(): MapLike { + /** Create a MapLike with good performance. */ + function createDictionaryObject(): MapLike { const map = Object.create(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. @@ -39,7 +39,7 @@ namespace ts { return map; } - export const sparseArray: () => SparseArray = createMapLike; + export const sparseArray: () => SparseArray = createDictionaryObject; /** Create a new map. If a template object is provided, the map will copy entries from it. */ export function createMap(template?: MapLike): Map { @@ -85,7 +85,7 @@ namespace ts { } return class implements Map { - private data = createMapLike(); + private data = createDictionaryObject(); public size = 0; get(key: string): T { @@ -115,7 +115,7 @@ namespace ts { } clear(): void { - this.data = createMapLike(); + this.data = createDictionaryObject(); this.size = 0; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 2ddc38499d0..cd44fbf7a3a 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -262,7 +262,7 @@ namespace Harness.LanguageService { this.getModuleResolutionsForFile = (fileName) => { const scriptInfo = this.getScriptInfo(fileName); const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true); - const imports = ts.createMapLike(); + const imports: ts.MapLike = {}; for (const module of preprocessInfo.importedFiles) { const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); if (resolutionInfo.resolvedModule) { @@ -275,7 +275,7 @@ namespace Harness.LanguageService { const scriptInfo = this.getScriptInfo(fileName); if (scriptInfo) { const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false); - const resolutions = ts.createMapLike(); + const resolutions: ts.MapLike = {}; const settings = this.nativeHost.getCompilationSettings(); for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) { const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost); From a8a1a826b3924c9d62841d01cd16c5b206abe3ee Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 28 Dec 2016 08:15:21 -0800 Subject: [PATCH 042/175] set the option when creating inferred projects --- src/server/editorServices.ts | 6 ++++++ src/server/project.ts | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 00df53e1e35..23b172d1cfe 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1079,6 +1079,12 @@ namespace ts.server { project, fileName => this.onConfigFileAddedForInferredProject(fileName)); + if (root.scriptKind === ScriptKind.JS || root.scriptKind === ScriptKind.JSX) { + const options = project.getCompilerOptions(); + options.maxNodeModuleJsDepth = 2; + project.setCompilerOptions(options); + } + project.updateGraph(); if (!useExistingProject) { diff --git a/src/server/project.ts b/src/server/project.ts index 2172b037d89..6085ee05159 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -169,13 +169,6 @@ namespace ts.server { this.compilerOptions.allowNonTsExtensions = true; } - if (this.projectKind === ProjectKind.Inferred) { - // Add default compiler options for inferred projects here - if (this.compilerOptions.maxNodeModuleJsDepth === undefined) { - this.compilerOptions.maxNodeModuleJsDepth = 2; - } - } - this.setInternalCompilerOptionsForEmittingJsFiles(); this.lsHost = new LSHost(this.projectService.host, this, this.projectService.cancellationToken); From f510897dbd5d1f8d0024c1b14243270dfe7006a3 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 28 Dec 2016 08:58:31 -0800 Subject: [PATCH 043/175] Remove "sparseArray" constructor function and just use array literals --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 2 -- src/compiler/factory.ts | 2 +- src/compiler/moduleNameResolver.ts | 6 +++--- src/compiler/transformers/generators.ts | 2 +- src/compiler/transformers/module/module.ts | 6 +++--- src/compiler/transformers/module/system.ts | 10 +++++----- src/compiler/transformers/ts.ts | 2 +- src/compiler/utilities.ts | 4 ++-- src/harness/unittests/session.ts | 2 +- src/harness/unittests/tsserverProjectSystem.ts | 4 ++-- src/services/codefixes/codeFixProvider.ts | 2 +- src/services/codefixes/importFixes.ts | 4 ++-- 13 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 165e4c3cca7..3ed4c383ef2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4084,7 +4084,7 @@ namespace ts { enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { const memberTypeList: Type[] = []; - const memberTypes = sparseArray(); + const memberTypes: SparseArray = []; for (const declaration of enumType.symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { computeEnumMemberValues(declaration); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index a7864a0646f..e9dbdb8786a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -39,8 +39,6 @@ namespace ts { return map; } - export const sparseArray: () => SparseArray = createDictionaryObject; - /** Create a new map. If a template object is provided, the map will copy entries from it. */ export function createMap(template?: MapLike): Map { const map: Map = new MapCtr(); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 661a0346f26..38e28fc2de0 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3299,7 +3299,7 @@ namespace ts { export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; const exportSpecifiers = createMap(); - const exportedBindings = sparseArray(); + const exportedBindings: SparseArray = []; const uniqueExports = createMap(); let exportedNames: Identifier[]; let hasExportDefault = false; diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index a8b634c0234..1efe9078f5a 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -388,7 +388,7 @@ namespace ts { } } } - + function getCommonPrefix(directory: Path, resolution: string) { if (resolution === undefined) { return undefined; @@ -418,7 +418,7 @@ namespace ts { trace(host, Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } const containingDirectory = getDirectoryPath(containingFile); - let perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); let result = perFolderCache && perFolderCache.get(moduleName); if (result) { @@ -991,7 +991,7 @@ namespace ts { * - { value: } - found - stop searching */ type SearchResult = { value: T | undefined } | undefined; - + /** * Wraps value to SearchResult. * @returns undefined if value is undefined or { value } otherwise diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 7cf7602efa0..8c9da9c4847 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -2096,7 +2096,7 @@ namespace ts { if (!renamedCatchVariables) { renamedCatchVariables = createMap(); - renamedCatchVariableDeclarations = sparseArray(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(SyntaxKind.Identifier); } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index e5e27c8360d..192f1f81a8f 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -39,8 +39,8 @@ namespace ts { context.enableSubstitution(SyntaxKind.ShorthandPropertyAssignment); // Substitutes shorthand property assignments for imported/exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap = sparseArray(); // The ExternalModuleInfo for each file. - const deferredExports = sparseArray(); // Exports to defer until an EndOfDeclarationMarker is found. + const moduleInfoMap: SparseArray = []; // The ExternalModuleInfo for each file. + const deferredExports: SparseArray = []; // Exports to defer until an EndOfDeclarationMarker is found. let currentSourceFile: SourceFile; // The current file. let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file. @@ -1105,7 +1105,7 @@ namespace ts { if (node.kind === SyntaxKind.SourceFile) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[getOriginalNodeId(currentSourceFile)]; - noSubstitution = sparseArray(); + noSubstitution = []; previousOnEmitNode(emitContext, node, emitCallback); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 5f23ccd0669..d332f3376b1 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -28,10 +28,10 @@ namespace ts { context.enableSubstitution(SyntaxKind.PostfixUnaryExpression); // Substitutes updates to exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap = sparseArray(); // The ExternalModuleInfo for each file. - const deferredExports = sparseArray(); // Exports to defer until an EndOfDeclarationMarker is found. - const exportFunctionsMap = sparseArray(); // The export function associated with a source file. - const noSubstitutionMap = sparseArray>(); // Set of nodes for which substitution rules should be ignored for each file. + const moduleInfoMap: SparseArray = []; // The ExternalModuleInfo for each file. + const deferredExports: SparseArray = []; // Exports to defer until an EndOfDeclarationMarker is found. + const exportFunctionsMap: SparseArray = []; // The export function associated with a source file. + const noSubstitutionMap: SparseArray> = []; // Set of nodes for which substitution rules should be ignored for each file. let currentSourceFile: SourceFile; // The current file. let moduleInfo: ExternalModuleInfo; // ExternalModuleInfo for the current file. @@ -1771,7 +1771,7 @@ namespace ts { * @param node The node which should not be substituted. */ function preventSubstitution(node: T): T { - if (noSubstitution === undefined) noSubstitution = sparseArray(); + if (noSubstitution === undefined) noSubstitution = []; noSubstitution[getNodeId(node)] = true; return node; } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 0947c894db8..96b00434660 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -3125,7 +3125,7 @@ namespace ts { context.enableSubstitution(SyntaxKind.Identifier); // Keep track of class aliases. - classAliases = sparseArray(); + classAliases = []; } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7fdda448ae8..44bb05dd4a8 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,4 @@ -/// +/// /* @internal */ namespace ts { @@ -3365,7 +3365,7 @@ namespace ts { return false; } - const syntaxKindCache = sparseArray(); + const syntaxKindCache: SparseArray = []; export function formatSyntaxKind(kind: SyntaxKind): string { const syntaxKindEnum = (ts).SyntaxKind; diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 70cda27747b..82f6ede865f 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -416,7 +416,7 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks = sparseArray<(resp: protocol.Response) => void>(); + private callbacks: SparseArray<(resp: protocol.Response) => void> = []; private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 98a34d2a3bb..4ae2dc7a389 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -292,7 +292,7 @@ namespace ts.projectSystem { } export class Callbacks { - private map = sparseArray(); + private map: SparseArray = []; private nextId = 1; register(cb: (...args: any[]) => void, args: any[]) { @@ -319,7 +319,7 @@ namespace ts.projectSystem { for (const key in this.map) { this.map[key](); } - this.map = sparseArray(); + this.map = []; } } diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index f4cb411b064..e1e3ef18865 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -16,7 +16,7 @@ namespace ts { } export namespace codefix { - const codeFixes = sparseArray(); + const codeFixes: SparseArray = []; export function registerCodeFix(action: CodeFix) { forEach(action.errorCodes, error => { diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 0df3c3134fe..81b299bf708 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -14,7 +14,7 @@ namespace ts.codefix { } class ImportCodeActionMap { - private symbolIdToActionMap = sparseArray(); + private symbolIdToActionMap: SparseArray = []; addAction(symbolId: number, newAction: ImportCodeAction) { if (!newAction) { @@ -125,7 +125,7 @@ namespace ts.codefix { const symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - const cachedImportDeclarations = sparseArray<(ImportDeclaration | ImportEqualsDeclaration)[]>(); + const cachedImportDeclarations: SparseArray<(ImportDeclaration | ImportEqualsDeclaration)[]> = []; let cachedNewImportInsertPosition: number; const allPotentialModules = checker.getAmbientModules(); From 39c19a74eae41dc83f44885bfa740d50e7b17c81 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 28 Dec 2016 09:05:52 -0800 Subject: [PATCH 044/175] Inline `keysOfMap` and `valuesOfMap`. --- src/compiler/commandLineParser.ts | 8 ++++---- src/compiler/core.ts | 18 +++--------------- src/compiler/tsc.ts | 2 +- src/harness/unittests/tsserverProjectSystem.ts | 2 +- src/server/project.ts | 6 +++--- src/services/documentRegistry.ts | 4 ++-- 6 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index a32a5137bad..7bf50f675aa 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -543,7 +543,7 @@ namespace ts { /* @internal */ export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic { - const namesOfType = keysOfMap(opt.type).map(key => `'${key}'`).join(", "); + const namesOfType = arrayFrom(opt.type.keys()).map(key => `'${key}'`).join(", "); return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType); } @@ -1255,8 +1255,8 @@ namespace ts { } } - const literalFiles = valuesOfMap(literalFileMap); - const wildcardFiles = valuesOfMap(wildcardFileMap); + const literalFiles = arrayFrom(literalFileMap.values()); + const wildcardFiles = arrayFrom(wildcardFileMap.values()); wildcardFiles.sort(host.useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); return { fileNames: literalFiles.concat(wildcardFiles), diff --git a/src/compiler/core.ts b/src/compiler/core.ts index e9dbdb8786a..9f8f1ba3f55 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -156,7 +156,7 @@ namespace ts { } function getKeys() { - return keysOfMap(files) as Path[]; + return arrayFrom(files.keys()) as Path[]; } // path should already be well-formed so it does not need to be normalized @@ -867,7 +867,8 @@ namespace ts { return keys; } - function arrayFrom(iterator: Iterator): T[] { + /** Shims `Array.from`. */ + export function arrayFrom(iterator: Iterator): T[] { const result: T[] = []; for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) { result.push(value); @@ -875,19 +876,6 @@ namespace ts { return result; } - /** - * Array of every key in a map. - * May not actually return string[] if numbers were put into the map. - */ - export function keysOfMap(map: Map<{}>): string[] { - return arrayFrom(map.keys()); - } - - /** Array of every value in a map. */ - export function valuesOfMap(map: Map): T[] { - return arrayFrom(map.values()); - } - /** * Calls `callback` for each entry in the map, returning the first defined result. * Use `map.forEach` instead for normal iteration. diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index ba5a0d8faea..a0e7d5ba323 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -680,7 +680,7 @@ namespace ts { description = getDiagnosticText(option.description); const element = (option).element; const typeMap = >element.type; - optionsDescriptionMap.set(description, keysOfMap(typeMap).map(key => `'${key}'`)); + optionsDescriptionMap.set(description, arrayFrom(typeMap.keys()).map(key => `'${key}'`)); } else { description = getDiagnosticText(option.description); diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 4ae2dc7a389..caa51cd5566 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -246,7 +246,7 @@ namespace ts.projectSystem { export function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { - assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${keysOfMap(map)}`); + assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${arrayFrom(map.keys())}`); } } diff --git a/src/server/project.ts b/src/server/project.ts index 505eb2f63fb..054b484392e 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -617,7 +617,7 @@ namespace ts.server { const added: string[] = []; const removed: string[] = []; - const updated: string[] = keysOfMap(updatedFileNames); + const updated: string[] = arrayFrom(updatedFileNames.keys()); forEachKeyInMap(currentFiles, id => { if (!lastReportedFileNames.has(id)) { @@ -691,7 +691,7 @@ namespace ts.server { }) } - const allFileNames = keysOfMap(referencedFiles) as Path[]; + const allFileNames = arrayFrom(referencedFiles.keys()) as Path[]; return filter(allFileNames, file => this.projectService.host.fileExists(file)); } diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index 4291abf6c1f..80b0133ccfe 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) @@ -121,7 +121,7 @@ namespace ts { } function reportStats() { - const bucketInfoArray = keysOfMap(buckets).filter(name => name && name.charAt(0) === "_").map(name => { + const bucketInfoArray = arrayFrom(buckets.keys()).filter(name => name && name.charAt(0) === "_").map(name => { const entries = buckets.get(name); const sourceFiles: { name: string; refCount: number; references: string[]; }[] = []; entries.forEachValue((key, entry) => { From 932eaa3f90c7418c6e4ce09cdab7ca30309e19ca Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 28 Dec 2016 09:16:38 -0800 Subject: [PATCH 045/175] Rename and consolidate map iteration helpers --- src/compiler/checker.ts | 10 ++--- src/compiler/commandLineParser.ts | 2 +- src/compiler/core.ts | 37 ++++--------------- src/compiler/declarationEmitter.ts | 2 +- src/compiler/program.ts | 2 +- .../unittests/cachingInServerLSHost.ts | 4 +- .../unittests/reuseProgramStructure.ts | 6 +-- src/server/editorServices.ts | 2 +- src/server/project.ts | 4 +- src/services/completions.ts | 4 +- src/services/findAllReferences.ts | 4 +- src/services/navigateTo.ts | 4 +- src/services/transpile.ts | 6 +-- 13 files changed, 32 insertions(+), 55 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3ed4c383ef2..b8e51c7f390 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1815,7 +1815,7 @@ namespace ts { } // Check if symbol is any of the alias - return forEachInMap(symbols, symbolFromSymbolTable => { + return forEachEntry(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { @@ -7758,7 +7758,7 @@ namespace ts { const maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up const destinationCache = (result === Ternary.True || depth === 0) ? relation : maybeStack[depth - 1]; - copyMapEntries(maybeCache, destinationCache); + copyEntries(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it @@ -18001,7 +18001,7 @@ namespace ts { else { const blockLocals = catchClause.block.locals; if (blockLocals) { - forEachKeyInMap(catchClause.locals, caughtName => { + forEachKey(catchClause.locals, caughtName => { const blockLocal = blockLocals.get(caughtName); if (blockLocal && (blockLocal.flags & SymbolFlags.BlockScopedVariable) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); @@ -19187,7 +19187,7 @@ namespace ts { } function hasExportedMembers(moduleSymbol: Symbol) { - return someInMap(moduleSymbol.exports, (_, id) => id !== "export="); + return forEachEntry(moduleSymbol.exports, (_, id) => id !== "export="); } function checkExternalModuleExports(node: SourceFile | ModuleDeclaration) { @@ -20097,7 +20097,7 @@ namespace ts { // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & SymbolFlags.Value) - : someInMap(getExportsOfModule(moduleSymbol), isValue); + : forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7bf50f675aa..3f89d3e3f9d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -753,7 +753,7 @@ namespace ts { function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: Map): string | undefined { // There is a typeMap associated with this command-line option so use it to map value back to its name - return forEachInMap(customTypeMap, (mapValue, key) => { + return forEachEntry(customTypeMap, (mapValue, key) => { if (mapValue === value) { return key; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 9f8f1ba3f55..effe24a253e 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -877,15 +877,15 @@ namespace ts { } /** - * Calls `callback` for each entry in the map, returning the first defined result. + * Calls `callback` for each entry in the map, returning the first truthy result. * Use `map.forEach` instead for normal iteration. */ - export function forEachInMap(map: Map, callback: (value: T, key: string) => U | undefined): U | undefined { + export function forEachEntry(map: Map, callback: (value: T, key: string) => U | undefined): U | undefined { const iterator = map.entries(); for (let { value: pair, done } = iterator.next(); !done; { value: pair, done } = iterator.next()) { const [key, value] = pair; const result = callback(value, key); - if (result !== undefined) { + if (result) { return result; } } @@ -893,42 +893,19 @@ namespace ts { } /** `forEachInMap` for just keys. */ - export function forEachKeyInMap(map: Map<{}>, callback: (key: string) => T | undefined): T | undefined { + export function forEachKey(map: Map<{}>, callback: (key: string) => T | undefined): T | undefined { const iterator = map.keys(); for (let { value: key, done } = iterator.next(); !done; { value: key, done } = iterator.next()) { const result = callback(key); - if (result !== undefined) { + if (result) { return result; } } return undefined; } - /** Whether `predicate` is true for some entry in the map. */ - export function someInMap(map: Map, predicate: (value: T, key: string) => boolean): boolean { - const iterator = map.entries(); - for (let { value: pair, done } = iterator.next(); !done; { value: pair, done } = iterator.next()) { - const [key, value] = pair; - if (predicate(value, key)) { - return true; - } - } - return false; - } - - /** `someInMap` for just keys. */ - export function someKeyInMap(map: Map<{}>, predicate: (key: string) => boolean): boolean { - const iterator = map.keys(); - for (let { value: key, done } = iterator.next(); !done; { value: key, done } = iterator.next()) { - if (predicate(key)) { - return true; - } - } - return false; - } - /** Copy entries from `source` to `target`. */ - export function copyMapEntries(source: Map, target: Map): void { + export function copyEntries(source: Map, target: Map): void { source.forEach((value, key) => { target.set(key, value); }); @@ -987,7 +964,7 @@ namespace ts { export function cloneMap(map: Map) { const clone = createMap(); - copyMapEntries(map, clone); + copyEntries(map, clone); return clone; } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index e010519d641..a006ab4fced 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -156,7 +156,7 @@ namespace ts { }); if (usedTypeDirectiveReferences) { - forEachKeyInMap(usedTypeDirectiveReferences, directive => { + forEachKey(usedTypeDirectiveReferences, directive => { referencesOutput += `/// ${newLine}`; }); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b6138e92a7b..324a21f229e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -464,7 +464,7 @@ namespace ts { classifiableNames = createMap(); for (const sourceFile of files) { - copyMapEntries(sourceFile.classifiableNames, classifiableNames); + copyEntries(sourceFile.classifiableNames, classifiableNames); } } diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index b6a90f53259..8389186c486 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts { interface File { @@ -8,7 +8,7 @@ namespace ts { function createDefaultServerHost(fileMap: Map): server.ServerHost { const existingDirectories = createMap(); - forEachKeyInMap(fileMap, name => { + forEachKey(fileMap, name => { let dir = getDirectoryPath(name); let previous: string; do { diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index eb4395154e4..8a89b8d27c6 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -197,13 +197,13 @@ namespace ts { function mapsAreEqual(left: Map, right: Map, valuesAreEqual?: (left: T, right: T) => boolean): boolean { if (left === right) return true; if (!left || !right) return false; - const someInLeftHasNoMatch = someInMap(left, (leftValue, leftKey) => { + const someInLeftHasNoMatch = forEachEntry(left, (leftValue, leftKey) => { if (!right.has(leftKey)) return true; const rightValue = right.get(leftKey); return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue); }); if (someInLeftHasNoMatch) return false; - const someInRightHasNoMatch = someKeyInMap(right, rightKey => !left.has(rightKey)); + const someInRightHasNoMatch = forEachKey(right, rightKey => !left.has(rightKey)); return !someInRightHasNoMatch; } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 239cd385f57..8865d821d29 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1373,7 +1373,7 @@ namespace ts.server { } // close projects that were missing in the input list - forEachKeyInMap(projectsToClose, externalProjectName => { + forEachKey(projectsToClose, externalProjectName => { this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true) }); diff --git a/src/server/project.ts b/src/server/project.ts index 054b484392e..94a08a485f9 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -619,12 +619,12 @@ namespace ts.server { const removed: string[] = []; const updated: string[] = arrayFrom(updatedFileNames.keys()); - forEachKeyInMap(currentFiles, id => { + forEachKey(currentFiles, id => { if (!lastReportedFileNames.has(id)) { added.push(id); } }); - forEachKeyInMap(lastReportedFileNames, id => { + forEachKey(lastReportedFileNames, id => { if (!currentFiles.has(id)) { removed.push(id); } diff --git a/src/services/completions.ts b/src/services/completions.ts index 4715222db08..04e3952b88b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,4 +1,4 @@ -/// +/// /* @internal */ namespace ts.Completions { @@ -378,7 +378,7 @@ namespace ts.Completions { } } - forEachKeyInMap(foundFiles, foundFile => { + forEachKey(foundFiles, foundFile => { result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); }); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 9e53537b69b..a7bf76e0656 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): ReferencedSymbol[] { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); @@ -508,7 +508,7 @@ namespace ts.FindAllReferences { result.push(ctrKeyword); } - forEachInMap(classSymbol.exports, member => { + classSymbol.exports.forEach(member => { const decl = member.valueDeclaration; if (decl && decl.kind === SyntaxKind.MethodDeclaration) { const body = (decl).body; diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 40f22941268..aa72da1ba5c 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 }; @@ -14,7 +14,7 @@ namespace ts.NavigateTo { continue; } - forEachInMap(sourceFile.getNamedDeclarations(), (declarations, name) => { + forEachEntry(sourceFile.getNamedDeclarations(), (declarations, name) => { if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. diff --git a/src/services/transpile.ts b/src/services/transpile.ts index d989a528497..b72399384b7 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; @@ -126,7 +126,7 @@ namespace ts { function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, o => - typeof o.type === "object" && !forEachInMap(o.type, v => typeof v !== "number")); + typeof o.type === "object" && !forEachEntry(o.type, v => typeof v !== "number")); options = clone(options); @@ -142,7 +142,7 @@ namespace ts { options[opt.name] = parseCustomTypeOption(opt, value, diagnostics); } else { - if (!someInMap(opt.type, v => v === value)) { + if (!forEachEntry(opt.type, v => v === value)) { // Supplied value isn't a valid enum value. diagnostics.push(createCompilerDiagnosticForInvalidCustomType(opt)); } From 145f0b2f18b2cc4ad69ed577920a541faf1ad123 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 28 Dec 2016 09:33:43 -0800 Subject: [PATCH 046/175] Add `createMultiMap` to replace `multiMapAdd` and `multiMapRemove` --- src/compiler/core.ts | 52 +++++++++---------- src/compiler/factory.ts | 16 +++++- src/compiler/sys.ts | 8 +-- src/harness/fourslash.ts | 4 +- .../unittests/tsserverProjectSystem.ts | 12 ++--- src/services/services.ts | 4 +- 6 files changed, 54 insertions(+), 42 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index effe24a253e..3669ece5104 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -989,43 +989,43 @@ namespace ts { return result; } - /** - * Adds the value to an array of values associated with the key, and returns the array. - * Creates the array if it does not already exist. - */ - export function multiMapAdd(map: Map, key: string, value: V): V[] { - let values = map.get(key); + export interface MultiMap extends Map { + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + add(key: string, value: T): T[]; + /** + * Removes a value from an array of values associated with the key. + * Does not preserve the order of those values. + * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. + */ + remove(key: string, value: T): void; + } + + export function createMultiMap(): MultiMap { + const map = createMap() as MultiMap; + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + function multiMapAdd(this: MultiMap, key: string, value: T) { + let values = this.get(key); if (values) { values.push(value); } else { - map.set(key, values = [value]); + this.set(key, values = [value]); } return values; - } - export function multiMapSparseArrayAdd(map: SparseArray, key: number, value: V): V[] { - let values = map[key]; - if (values) { - values.push(value); - } - else { - map[key] = values = [value]; - } - return values; } - - /** - * Removes a value from an array of values associated with the key. - * Does not preserve the order of those values. - * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. - */ - export function multiMapRemove(map: Map, key: string, value: V): void { - const values = map.get(key); + function multiMapRemove(this: MultiMap, key: string, value: T) { + const values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - map.delete(key); + this.delete(key); } } } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 38e28fc2de0..06108f2d0b2 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3298,7 +3298,7 @@ namespace ts { export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; - const exportSpecifiers = createMap(); + const exportSpecifiers = createMultiMap(); const exportedBindings: SparseArray = []; const uniqueExports = createMap(); let exportedNames: Identifier[]; @@ -3352,7 +3352,7 @@ namespace ts { for (const specifier of (node).exportClause.elements) { if (!uniqueExports.get(specifier.name.text)) { const name = specifier.propertyName || specifier.name; - multiMapAdd(exportSpecifiers, name.text, specifier); + exportSpecifiers.add(name.text, specifier); const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); @@ -3446,4 +3446,16 @@ namespace ts { } return exportedNames; } + + /** Use a sparse array as a multi-map. */ + function multiMapSparseArrayAdd(map: SparseArray, key: number, value: V): V[] { + let values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index b10d746e435..3c28efd0de8 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts { export type FileWatcherCallback = (fileName: string, removed?: boolean) => void; @@ -243,7 +243,7 @@ namespace ts { function createWatchedFileSet() { const dirWatchers = createMap(); // One file can have multiple watchers - const fileWatcherCallbacks = createMap(); + const fileWatcherCallbacks = createMultiMap(); return { addFile, removeFile }; function reduceDirWatcherRefCountForFile(fileName: string) { @@ -275,7 +275,7 @@ namespace ts { } function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void { - multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { @@ -291,7 +291,7 @@ namespace ts { } function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) { - multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: string) { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 04fd55b110e..8b127afa081 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1760,10 +1760,10 @@ namespace FourSlash { } public rangesByText(): ts.Map { - const result = ts.createMap(); + const result = ts.createMultiMap(); for (const range of this.getRanges()) { const text = this.rangeText(range); - ts.multiMapAdd(result, text, range); + result.add(text, range); } return result; } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index caa51cd5566..c8729d49497 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -334,8 +334,8 @@ namespace ts.projectSystem { private timeoutCallbacks = new Callbacks(); private immediateCallbacks = new Callbacks(); - readonly watchedDirectories = createMap<{ cb: DirectoryWatcherCallback, recursive: boolean }[]>(); - readonly watchedFiles = createMap(); + readonly watchedDirectories = createMultiMap<{ cb: DirectoryWatcherCallback, recursive: boolean }>(); + readonly watchedFiles = createMultiMap(); private filesOrFolders: FileOrFolder[]; @@ -421,11 +421,11 @@ namespace ts.projectSystem { watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher { const path = this.toPath(directoryName); const cbWithRecursive = { cb: callback, recursive }; - multiMapAdd(this.watchedDirectories, path, cbWithRecursive); + this.watchedDirectories.add(path, cbWithRecursive); return { referenceCount: 0, directoryName, - close: () => multiMapRemove(this.watchedDirectories, path, cbWithRecursive) + close: () => this.watchedDirectories.remove(path, cbWithRecursive) }; } @@ -455,8 +455,8 @@ namespace ts.projectSystem { watchFile(fileName: string, callback: FileWatcherCallback) { const path = this.toPath(fileName); - multiMapAdd(this.watchedFiles, path, callback); - return { close: () => multiMapRemove(this.watchedFiles, path, callback) }; + this.watchedFiles.add(path, callback); + return { close: () => this.watchedFiles.remove(path, callback) }; } // TOOD: record and invoke callbacks to simulate timer events diff --git a/src/services/services.ts b/src/services/services.ts index 7cd2dce196d..86fbf22b71a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -518,7 +518,7 @@ namespace ts { } private computeNamedDeclarations(): Map { - const result = createMap(); + const result = createMultiMap(); forEachChild(this, visit); @@ -527,7 +527,7 @@ namespace ts { function addDeclaration(declaration: Declaration) { const name = getDeclarationName(declaration); if (name) { - multiMapAdd(result, name, declaration); + result.add(name, declaration); } } From 2e6f369e8fa15ad75668467d1dbcb2b411d7f75d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 28 Dec 2016 09:39:58 -0800 Subject: [PATCH 047/175] Replace SparseArray with T[] --- src/compiler/checker.ts | 2 +- src/compiler/factory.ts | 8 ++++---- src/compiler/transformers/generators.ts | 2 +- src/compiler/transformers/module/module.ts | 6 +++--- src/compiler/transformers/module/system.ts | 10 +++++----- src/compiler/transformers/ts.ts | 2 +- src/compiler/types.ts | 11 ++--------- src/compiler/utilities.ts | 2 +- src/harness/unittests/session.ts | 2 +- src/harness/unittests/tsserverProjectSystem.ts | 2 +- src/services/codefixes/codeFixProvider.ts | 2 +- src/services/codefixes/importFixes.ts | 4 ++-- 12 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fcc44ba087f..48a0876d881 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4084,7 +4084,7 @@ namespace ts { enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { const memberTypeList: Type[] = []; - const memberTypes: SparseArray = []; + const memberTypes: EnumLiteralType[] = []; for (const declaration of enumType.symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { computeEnumMemberValues(declaration); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index a326c0c0475..f63094ae16d 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2646,7 +2646,7 @@ namespace ts { return destEmitNode; } - function mergeTokenSourceMapRanges(sourceRanges: SparseArray, destRanges: SparseArray) { + function mergeTokenSourceMapRanges(sourceRanges: TextRange[], destRanges: TextRange[]) { if (!destRanges) destRanges = []; for (const key in sourceRanges) { destRanges[key] = sourceRanges[key]; @@ -3277,7 +3277,7 @@ namespace ts { externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers exportSpecifiers: Map; // export specifiers by name - exportedBindings: SparseArray; // exported names of local declarations + exportedBindings: Identifier[][]; // exported names of local declarations exportedNames: Identifier[]; // all exported names local to module exportEquals: ExportAssignment | undefined; // an export= declaration if one was present hasExportStarsToExportValues: boolean; // whether this module contains export* @@ -3286,7 +3286,7 @@ namespace ts { export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; const exportSpecifiers = createMultiMap(); - const exportedBindings: SparseArray = []; + const exportedBindings: Identifier[][] = []; const uniqueExports = createMap(); let exportedNames: Identifier[]; let hasExportDefault = false; @@ -3435,7 +3435,7 @@ namespace ts { } /** Use a sparse array as a multi-map. */ - function multiMapSparseArrayAdd(map: SparseArray, key: number, value: V): V[] { + function multiMapSparseArrayAdd(map: V[][], key: number, value: V): V[] { let values = map[key]; if (values) { values.push(value); diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 8c9da9c4847..7dcfe76a427 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -243,7 +243,7 @@ namespace ts { let currentSourceFile: SourceFile; let renamedCatchVariables: Map; - let renamedCatchVariableDeclarations: SparseArray; + let renamedCatchVariableDeclarations: Identifier[]; let inGeneratorFunctionBody: boolean; let inStatementContainingYield: boolean; diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index b42f4bf4bee..0adea4fd540 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -39,12 +39,12 @@ namespace ts { context.enableSubstitution(SyntaxKind.ShorthandPropertyAssignment); // Substitutes shorthand property assignments for imported/exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap: SparseArray = []; // The ExternalModuleInfo for each file. - const deferredExports: SparseArray = []; // Exports to defer until an EndOfDeclarationMarker is found. + const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file. + const deferredExports: Statement[][] = []; // Exports to defer until an EndOfDeclarationMarker is found. let currentSourceFile: SourceFile; // The current file. let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file. - let noSubstitution: SparseArray; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index d332f3376b1..3f1488b649d 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -28,10 +28,10 @@ namespace ts { context.enableSubstitution(SyntaxKind.PostfixUnaryExpression); // Substitutes updates to exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap: SparseArray = []; // The ExternalModuleInfo for each file. - const deferredExports: SparseArray = []; // Exports to defer until an EndOfDeclarationMarker is found. - const exportFunctionsMap: SparseArray = []; // The export function associated with a source file. - const noSubstitutionMap: SparseArray> = []; // Set of nodes for which substitution rules should be ignored for each file. + const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file. + const deferredExports: Statement[][] = []; // Exports to defer until an EndOfDeclarationMarker is found. + const exportFunctionsMap: Identifier[] = []; // The export function associated with a source file. + const noSubstitutionMap: boolean[][] = []; // Set of nodes for which substitution rules should be ignored for each file. let currentSourceFile: SourceFile; // The current file. let moduleInfo: ExternalModuleInfo; // ExternalModuleInfo for the current file. @@ -39,7 +39,7 @@ namespace ts { let contextObject: Identifier; // The context object for the current file. let hoistedStatements: Statement[]; let enclosingBlockScopedContainer: Node; - let noSubstitution: SparseArray; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 96b00434660..e2b8b8fe2ec 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -60,7 +60,7 @@ namespace ts { * A map that keeps track of aliases created for classes with decorators to avoid issues * with the double-binding behavior of classes. */ - let classAliases: SparseArray; + let classAliases: Identifier[]; /** * Keeps track of whether we are within any containing namespaces when performing diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d734998cd7f..2489434c82d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -8,13 +8,6 @@ [index: string]: T; } - /** - * Like MapLike, but keys must be numbers. - */ - export interface SparseArray { - [key: number]: T; - } - /** ES6 Map interface. */ export interface Map { get(key: string): T; @@ -2854,7 +2847,7 @@ // Enum types (TypeFlags.Enum) export interface EnumType extends Type { - memberTypes: SparseArray; + memberTypes: EnumLiteralType[]; } // Enum types (TypeFlags.EnumLiteral) @@ -3684,7 +3677,7 @@ flags?: EmitFlags; // Flags that customize emit commentRange?: TextRange; // The text range to use when emitting leading or trailing comments sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings - tokenSourceMapRanges?: SparseArray; // The text range to use when emitting source mappings for tokens + tokenSourceMapRanges?: TextRange[]; // The text range to use when emitting source mappings for tokens constantValue?: number; // The constant value of an expression externalHelpersModuleName?: Identifier; // The local name for an imported helpers module helpers?: EmitHelper[]; // Emit helpers for the node diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5e15d97752b..f74c450d61a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3362,7 +3362,7 @@ namespace ts { return false; } - const syntaxKindCache: SparseArray = []; + const syntaxKindCache: string[] = []; export function formatSyntaxKind(kind: SyntaxKind): string { const syntaxKindEnum = (ts).SyntaxKind; diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 82f6ede865f..15c43d9e76b 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -416,7 +416,7 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks: SparseArray<(resp: protocol.Response) => void> = []; + private callbacks: Array<(resp: protocol.Response) => void> = []; private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 4d4873465b5..b2e2eca2951 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -292,7 +292,7 @@ namespace ts.projectSystem { } export class Callbacks { - private map: SparseArray = []; + private map: TimeOutCallback[] = []; private nextId = 1; register(cb: (...args: any[]) => void, args: any[]) { diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index e1e3ef18865..10d0b8eef34 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -16,7 +16,7 @@ namespace ts { } export namespace codefix { - const codeFixes: SparseArray = []; + const codeFixes: CodeFix[][] = []; export function registerCodeFix(action: CodeFix) { forEach(action.errorCodes, error => { diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 81b299bf708..8cd0a9664a0 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -14,7 +14,7 @@ namespace ts.codefix { } class ImportCodeActionMap { - private symbolIdToActionMap: SparseArray = []; + private symbolIdToActionMap: ImportCodeAction[][] = []; addAction(symbolId: number, newAction: ImportCodeAction) { if (!newAction) { @@ -125,7 +125,7 @@ namespace ts.codefix { const symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - const cachedImportDeclarations: SparseArray<(ImportDeclaration | ImportEqualsDeclaration)[]> = []; + const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; let cachedNewImportInsertPosition: number; const allPotentialModules = checker.getAmbientModules(); From bf5faa04a636dc9633c90a9ee4dadb1a85a78fc8 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 28 Dec 2016 14:46:58 -0800 Subject: [PATCH 048/175] Use inherited setCompilerOptions for inferred project --- .../unittests/tsserverProjectSystem.ts | 8 ++++--- src/server/editorServices.ts | 10 ++++---- src/server/project.ts | 23 ++++++++++++++++--- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index e1ac647c2ac..dbf9bf670e6 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3068,9 +3068,11 @@ namespace ts.projectSystem { projectService.openClientFile(file1.path); const project = projectService.inferredProjects[0]; - const sourceFile = project.getSourceFile(file1.path); - assert.isTrue("test" in sourceFile.resolvedModules); - assert.equal((sourceFile.resolvedModules["test"]).resolvedFileName, moduleFile.path); + const sourceFileForFile1 = project.getSourceFile(file1.path); + const sourceFileForModuleFile = project.getSourceFile(moduleFile.path); + + assert.isNotNull(sourceFileForFile1); + assert.isNotNull(sourceFileForModuleFile); }); }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 23b172d1cfe..eba0dbb119c 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1072,6 +1072,10 @@ namespace ts.server { ? this.inferredProjects[0] : new InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); + if (root.scriptKind === ScriptKind.JS || root.scriptKind === ScriptKind.JSX) { + project.isJsInferredProject = true; + } + project.addRoot(root); this.directoryWatchers.startWatchingContainingDirectoriesForFile( @@ -1079,12 +1083,6 @@ namespace ts.server { project, fileName => this.onConfigFileAddedForInferredProject(fileName)); - if (root.scriptKind === ScriptKind.JS || root.scriptKind === ScriptKind.JSX) { - const options = project.getCompilerOptions(); - options.maxNodeModuleJsDepth = 2; - project.setCompilerOptions(options); - } - project.updateGraph(); if (!useExistingProject) { diff --git a/src/server/project.ts b/src/server/project.ts index 6085ee05159..ca3950a48a8 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -566,9 +566,6 @@ namespace ts.server { setCompilerOptions(compilerOptions: CompilerOptions) { if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; - } compilerOptions.allowNonTsExtensions = true; if (changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { // reset cached unresolved imports if changes in compiler options affected module resolution @@ -715,6 +712,26 @@ namespace ts.server { } })(); + private _isJsInferredProject = false; + set isJsInferredProject(newValue: boolean) { + if (newValue && !this._isJsInferredProject) { + this.setCompilerOptions(this.getCompilerOptions()); + } + this._isJsInferredProject = newValue; + } + + setCompilerOptions(newOptions: CompilerOptions) { + if (!newOptions) { + return; + } + + if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { + newOptions.maxNodeModuleJsDepth = 2; + } + newOptions.allowJs = true; + super.setCompilerOptions(newOptions); + } + // Used to keep track of what directories are watched for this project directoriesWatchedForTsconfig: string[] = []; From 09fc3b3a181e6babb9ad4dee2fd5166385793839 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Thu, 29 Dec 2016 10:26:34 -0800 Subject: [PATCH 049/175] address cr feedback --- src/harness/unittests/tsserverProjectSystem.ts | 13 ++++++++----- src/server/editorServices.ts | 2 +- src/server/project.ts | 12 ++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index dbf9bf670e6..a766a9c4230 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3067,12 +3067,15 @@ namespace ts.projectSystem { const projectService = createProjectService(host); projectService.openClientFile(file1.path); - const project = projectService.inferredProjects[0]; - const sourceFileForFile1 = project.getSourceFile(file1.path); - const sourceFileForModuleFile = project.getSourceFile(moduleFile.path); + let project = projectService.inferredProjects[0]; + let options = project.getCompilerOptions(); + assert.isTrue(options.maxNodeModuleJsDepth === 2); - assert.isNotNull(sourceFileForFile1); - assert.isNotNull(sourceFileForModuleFile); + // Assert the option sticks + projectService.setCompilerOptionsForInferredProjects({ target: ScriptTarget.ES2016 }); + project = projectService.inferredProjects[0]; + options = project.getCompilerOptions(); + assert.isTrue(options.maxNodeModuleJsDepth === 2); }); }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index eba0dbb119c..2b87fdf1cc7 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1073,7 +1073,7 @@ namespace ts.server { : new InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); if (root.scriptKind === ScriptKind.JS || root.scriptKind === ScriptKind.JSX) { - project.isJsInferredProject = true; + project.setAsJsInferredProject(); } project.addRoot(root); diff --git a/src/server/project.ts b/src/server/project.ts index ca3950a48a8..5178820b3c4 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -713,14 +713,14 @@ namespace ts.server { })(); private _isJsInferredProject = false; - set isJsInferredProject(newValue: boolean) { - if (newValue && !this._isJsInferredProject) { - this.setCompilerOptions(this.getCompilerOptions()); - } - this._isJsInferredProject = newValue; + + setAsJsInferredProject() { + this._isJsInferredProject = true; + this.setCompilerOptions(); } - setCompilerOptions(newOptions: CompilerOptions) { + setCompilerOptions(newOptions?: CompilerOptions) { + newOptions = newOptions ? newOptions : this.getCompilerOptions(); if (!newOptions) { return; } From 8ac22ecbb04df7fc6bccec93a10fa38a4eea94da Mon Sep 17 00:00:00 2001 From: zhengbli Date: Thu, 29 Dec 2016 17:00:04 -0800 Subject: [PATCH 050/175] Change the design to track addRoot and removeRoot --- .../unittests/tsserverProjectSystem.ts | 31 ++++++++++++- src/server/editorServices.ts | 4 -- src/server/project.ts | 44 ++++++++++++++----- src/server/scriptInfo.ts | 4 ++ 4 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index a766a9c4230..1844b0743ca 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1620,7 +1620,7 @@ namespace ts.projectSystem { const configureHostRequest = makeSessionRequest(CommandNames.Configure, { extraFileExtensions }); session.executeCommand(configureHostRequest).response; - // HTML file still not included in the project as it is closed + // HTML file still not included in the project as it is closed checkNumberOfProjects(projectService, { configuredProjects: 1 }); checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]); @@ -3053,7 +3053,7 @@ namespace ts.projectSystem { }); describe("maxNodeModuleJsDepth for inferred projects", () => { - it("should be set by default", () => { + it("should be set to 2 if the project has js root files", () => { const file1: FileOrFolder = { path: "/a/b/file1.js", content: `var t = require("test"); t.` @@ -3077,6 +3077,33 @@ namespace ts.projectSystem { options = project.getCompilerOptions(); assert.isTrue(options.maxNodeModuleJsDepth === 2); }); + + it("should return to normal state when all js root files are removed from project", () => { + const file1 = { + path: "/a/file1.ts", + content: "let x =1;" + }; + const file2 = { + path: "/a/file2.js", + content: "let x =1;" + }; + + const host = createServerHost([file1, file2, libFile]); + const projectService = createProjectService(host, { useSingleInferredProject: true }); + + projectService.openClientFile(file1.path); + checkNumberOfInferredProjects(projectService, 1); + let project = projectService.inferredProjects[0]; + assert.isUndefined(project.getCompilerOptions().maxNodeModuleJsDepth); + + projectService.openClientFile(file2.path); + project = projectService.inferredProjects[0]; + assert.isTrue(project.getCompilerOptions().maxNodeModuleJsDepth === 2); + + projectService.closeClientFile(file2.path); + project = projectService.inferredProjects[0]; + assert.isUndefined(project.getCompilerOptions().maxNodeModuleJsDepth); + }); }); } \ No newline at end of file diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 2b87fdf1cc7..00df53e1e35 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1072,10 +1072,6 @@ namespace ts.server { ? this.inferredProjects[0] : new InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); - if (root.scriptKind === ScriptKind.JS || root.scriptKind === ScriptKind.JSX) { - project.setAsJsInferredProject(); - } - project.addRoot(root); this.directoryWatchers.startWatchingContainingDirectoriesForFile( diff --git a/src/server/project.ts b/src/server/project.ts index 5178820b3c4..89312610a54 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -395,7 +395,9 @@ namespace ts.server { } removeFile(info: ScriptInfo, detachFromProject = true) { - this.removeRootFileIfNecessary(info); + if (this.isRoot(info)) { + this.removeRoot(info); + } this.lsHost.notifyFileRemoved(info); this.cachedUnresolvedImportsPerFile.remove(info.path); @@ -693,11 +695,9 @@ namespace ts.server { } // remove a root file from project - private removeRootFileIfNecessary(info: ScriptInfo): void { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } + protected removeRoot(info: ScriptInfo): void { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); } } @@ -714,13 +714,16 @@ namespace ts.server { private _isJsInferredProject = false; - setAsJsInferredProject() { - this._isJsInferredProject = true; - this.setCompilerOptions(); + toggleJsInferredProject(isJsInferredProject: boolean) { + if (isJsInferredProject !== this._isJsInferredProject) { + this._isJsInferredProject = isJsInferredProject; + this.setCompilerOptions(); + } } - setCompilerOptions(newOptions?: CompilerOptions) { - newOptions = newOptions ? newOptions : this.getCompilerOptions(); + setCompilerOptions(options?: CompilerOptions) { + // Avoid manipulating the given options directly + const newOptions = options ? clone(options) : this.getCompilerOptions(); if (!newOptions) { return; } @@ -728,6 +731,9 @@ namespace ts.server { if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { newOptions.maxNodeModuleJsDepth = 2; } + else if (!this._isJsInferredProject) { + newOptions.maxNodeModuleJsDepth = undefined; + } newOptions.allowJs = true; super.setCompilerOptions(newOptions); } @@ -746,6 +752,22 @@ namespace ts.server { /*compileOnSaveEnabled*/ false); } + addRoot(info: ScriptInfo) { + if (!this._isJsInferredProject && info.isJavaScript()) { + this.toggleJsInferredProject(/*isJsInferredProject*/ true); + } + super.addRoot(info); + } + + removeRoot(info: ScriptInfo) { + if (this._isJsInferredProject && info.isJavaScript()) { + if (filter(this.getRootScriptInfos(), info => info.isJavaScript()).length === 0) { + this.toggleJsInferredProject(/*isJsInferredProject*/ false); + } + } + super.removeRoot(info); + } + getProjectRootPath() { // Single inferred project does not have a project root. if (this.projectService.useSingleInferredProject) { diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 0acd45d0287..a93600de1a8 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -355,5 +355,9 @@ namespace ts.server { positionToLineOffset(position: number): ILineInfo { return this.textStorage.positionToLineOffset(position); } + + public isJavaScript() { + return this.scriptKind === ScriptKind.JS || this.scriptKind === ScriptKind.JSX; + } } } \ No newline at end of file From 544d0a43880b3ee6043aae28f8f09210221f60c4 Mon Sep 17 00:00:00 2001 From: about-code Date: Fri, 30 Dec 2016 13:03:20 +0100 Subject: [PATCH 051/175] Incorporate changes proposed by @sandersn --- src/compiler/checker.ts | 52 ++++++++++++++++------------ src/compiler/diagnosticMessages.json | 8 ++--- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b3820bc0970..4395e852ebc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2142,24 +2142,25 @@ namespace ts { return type.flags & TypeFlags.StringLiteral ? `"${escapeString((type).text)}"` : (type).text; } - function getSymbolDisplayBuilder(): SymbolDisplayBuilder { - function getNameOfSymbol(symbol: Symbol): string { - if (symbol.declarations && symbol.declarations.length) { - const declaration = symbol.declarations[0]; - if (declaration.name) { - return declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case SyntaxKind.ClassExpression: - return "(Anonymous class)"; - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - return "(Anonymous function)"; - } + function getNameOfSymbol(symbol: Symbol): string { + if (symbol.declarations && symbol.declarations.length) { + const declaration = symbol.declarations[0]; + if (declaration.name) { + return declarationNameToString(declaration.name); + } + switch (declaration.kind) { + case SyntaxKind.ClassExpression: + return "(Anonymous class)"; + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + + function getSymbolDisplayBuilder(): SymbolDisplayBuilder { /** * Writes only the name of the symbol out to the writer. Uses the original source text @@ -15647,20 +15648,27 @@ namespace ts { } } - // Static members may conflict with non-configurable non-writable built-in Function object properties - // see https://github.com/microsoft/typescript/issues/442. + /** + * Static members being set on a constructor function may conflict with built-in Function + * object properties. Esp. in ECMAScript 5 there are non-configurable and non-writable + * built-in properties. This check issues a transpile error when a class has a static + * member with the same name as a non-writable built-in property. + * + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances + */ function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; - const className = getSymbolOfNode(node).name; + const className = getNameOfSymbol(getSymbolOfNode(node)); for (const member of node.members) { - const isStatic = forEach(member.modifiers, (m: Modifier) => m.kind === SyntaxKind.StaticKeyword); + const isStatic = getModifierFlags(member) & ModifierFlags.Static; const isMethod = member.kind === SyntaxKind.MethodDeclaration; const memberNameNode = member.name; if (isStatic && memberNameNode) { const memberName = getPropertyNameForPropertyNameNode(memberNameNode); if (languageVersion <= ScriptTarget.ES5) { // ES3, ES5 - // see also http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 - // see also http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 if (memberName === "prototype" || memberName === "name" || memberName === "length" || @@ -15671,8 +15679,6 @@ namespace ts { } } else { // ES6+ - // see also http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor - // see also http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances if (memberName === "prototype") { error(memberNameNode, message, memberName, className); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0c9bb74f781..476cced3732 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2011,14 +2011,14 @@ "category": "Error", "code": 2697 }, - "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'.": { - "category": "Error", - "code": 2699 - }, "Spread types may only be created from object types.": { "category": "Error", "code": 2698 }, + "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'.": { + "category": "Error", + "code": 2699 + }, "Rest types may only be created from object types.": { "category": "Error", "code": 2700 From 8b44ce2fd7bc70a89721db3dd5db3b1ec0e6ea0d Mon Sep 17 00:00:00 2001 From: Joel Day Date: Sat, 31 Dec 2016 17:37:51 -0800 Subject: [PATCH 052/175] Emitting tsserverlibrary as an external module. --- Gulpfile.ts | 3 ++ Jakefile.js | 38 +++++++++---------- src/server/shared.ts | 2 +- src/server/tsconfig.library.json | 14 ++++--- src/server/{types.d.ts => types.ts} | 0 src/server/typingsInstaller/tsconfig.json | 2 +- .../typingsInstaller/typingsInstaller.ts | 2 +- src/server/utilities.ts | 2 +- 8 files changed, 35 insertions(+), 28 deletions(-) rename src/server/{types.d.ts => types.ts} (100%) diff --git a/Gulpfile.ts b/Gulpfile.ts index 054e99c8003..2eec5c22045 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -472,6 +472,9 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { .pipe(sourcemaps.write(".")) .pipe(gulp.dest(".")), dts.pipe(prependCopyright()) + .pipe(insert.transform((content) => { + return content + "\r\nexport = ts;"; + })) .pipe(gulp.dest(".")) ]); }); diff --git a/Jakefile.js b/Jakefile.js index 3c26003fdf0..801ac924027 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -183,8 +183,8 @@ var servicesSources = [ return path.join(servicesDirectory, f); })); -var serverCoreSources = [ - "types.d.ts", +var baseServerCoreSources = [ + "types.ts", "shared.ts", "utilities.ts", "scriptVersionCache.ts", @@ -195,11 +195,16 @@ var serverCoreSources = [ "editorServices.ts", "protocol.ts", "session.ts", - "server.ts" ].map(function (f) { return path.join(serverDirectory, f); }); +var serverCoreSources = [ + "server.ts" +].map(function (f) { + return path.join(serverDirectory, f); +}).concat(baseServerCoreSources); + var cancellationTokenSources = [ "cancellationToken.ts" ].map(function (f) { @@ -207,7 +212,7 @@ var cancellationTokenSources = [ }); var typingsInstallerSources = [ - "../types.d.ts", + "../types.ts", "../shared.ts", "typingsInstaller.ts", "nodeTypingsInstaller.ts" @@ -216,20 +221,7 @@ var typingsInstallerSources = [ }); var serverSources = serverCoreSources.concat(servicesSources); - -var languageServiceLibrarySources = [ - "protocol.ts", - "utilities.ts", - "scriptVersionCache.ts", - "scriptInfo.ts", - "lsHost.ts", - "project.ts", - "editorServices.ts", - "session.ts", - -].map(function (f) { - return path.join(serverDirectory, f); -}).concat(servicesSources); +var languageServiceLibrarySources = baseServerCoreSources.concat(servicesSources); var harnessCoreSources = [ "harness.ts", @@ -727,7 +719,15 @@ compileFile( [builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets), /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - { noOutFile: false, generateDeclarations: true }); + { noOutFile: false, generateDeclarations: true }, + /*callback*/ function () { + + prependFile(copyright, tsserverLibraryDefinitionFile); + + // Appending 'export = ts;' at the end of the server library file to turn it into an external module + var tsserverLibraryDefinitionFileContents = fs.readFileSync(tsserverLibraryDefinitionFile).toString() + "\r\nexport = ts;"; + fs.writeFileSync(tsserverLibraryDefinitionFile, tsserverLibraryDefinitionFileContents); + }); // Local target to build the language service server library desc("Builds language service server library"); diff --git a/src/server/shared.ts b/src/server/shared.ts index c56d4098e75..77f66fc5a2d 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts.server { export const ActionSet: ActionSet = "action::set"; diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 5483cc8ec28..c589d875c3a 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -1,16 +1,20 @@ { "compilerOptions": { "noImplicitAny": true, + "noImplicitThis": true, "removeComments": true, "preserveConstEnums": true, + "pretty": true, "outFile": "../../built/local/tsserverlibrary.js", "sourceMap": true, "stripInternal": true, - "declaration": true, - "types": [], + "types": [ + "node" + ], "target": "es5", "noUnusedLocals": true, - "noUnusedParameters": true + "noUnusedParameters": true, + "declaration": true }, "files": [ "../services/shims.ts", @@ -19,11 +23,11 @@ "utilities.ts", "scriptVersionCache.ts", "scriptInfo.ts", - "lshost.ts", + "lsHost.ts", "typingsCache.ts", "project.ts", "editorServices.ts", - "protocol.d.ts", + "protocol.ts", "session.ts" ] } diff --git a/src/server/types.d.ts b/src/server/types.ts similarity index 100% rename from src/server/types.d.ts rename to src/server/types.ts diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index c6031b19aae..27f5cedc9d1 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -16,7 +16,7 @@ "noUnusedParameters": true }, "files": [ - "../types.d.ts", + "../types.ts", "../shared.ts", "typingsInstaller.ts", "nodeTypingsInstaller.ts" diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 7a09c1f6c21..f706943a0f5 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -1,7 +1,7 @@ /// /// /// -/// +/// /// namespace ts.server.typingsInstaller { diff --git a/src/server/utilities.ts b/src/server/utilities.ts index d0790b93dba..1889b055d29 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.server { From cf5508732a520cd8ef26a071c9aab51e58a49087 Mon Sep 17 00:00:00 2001 From: Joel Day Date: Sun, 1 Jan 2017 17:58:33 -0800 Subject: [PATCH 053/175] Fix Gulp build of tsserverlibrary to match Jake. --- Gulpfile.ts | 2 +- Jakefile.js | 14 +++++++------- src/server/tsconfig.library.json | 26 +++++++++++++------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 2eec5c22045..22bf020a435 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -471,7 +471,7 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { js.pipe(prependCopyright()) .pipe(sourcemaps.write(".")) .pipe(gulp.dest(".")), - dts.pipe(prependCopyright()) + dts.pipe(prependCopyright(/*outputCopyright*/true)) .pipe(insert.transform((content) => { return content + "\r\nexport = ts;"; })) diff --git a/Jakefile.js b/Jakefile.js index 801ac924027..b810477d861 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -184,17 +184,17 @@ var servicesSources = [ })); var baseServerCoreSources = [ - "types.ts", - "shared.ts", - "utilities.ts", - "scriptVersionCache.ts", - "typingsCache.ts", - "scriptInfo.ts", + "editorServices.ts", "lsHost.ts", "project.ts", - "editorServices.ts", "protocol.ts", + "scriptInfo.ts", + "scriptVersionCache.ts", "session.ts", + "shared.ts", + "types.ts", + "typingsCache.ts", + "utilities.ts", ].map(function (f) { return path.join(serverDirectory, f); }); diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index c589d875c3a..397211e6ff4 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -2,12 +2,11 @@ "compilerOptions": { "noImplicitAny": true, "noImplicitThis": true, - "removeComments": true, + "removeComments": false, "preserveConstEnums": true, "pretty": true, "outFile": "../../built/local/tsserverlibrary.js", "sourceMap": true, - "stripInternal": true, "types": [ "node" ], @@ -17,17 +16,18 @@ "declaration": true }, "files": [ - "../services/shims.ts", - "../services/utilities.ts", - "shared.ts", - "utilities.ts", - "scriptVersionCache.ts", - "scriptInfo.ts", - "lsHost.ts", - "typingsCache.ts", - "project.ts", "editorServices.ts", - "protocol.ts", - "session.ts" + "lsHost.ts", + "project.ts", + "protocol.d.ts", + "scriptInfo.ts", + "scriptVersionCache.ts", + "session.ts", + "shared.ts", + "types.ts", + "typingsCache.ts", + "utilities.ts", + "../services/shims.ts", + "../services/utilities.ts" ] } From 244db70730e90bcfa69b00c8f8b8f6973d641bda Mon Sep 17 00:00:00 2001 From: about-code Date: Tue, 3 Jan 2017 14:06:10 +0100 Subject: [PATCH 054/175] Incorporating changes to `checkClassForDuplicateDeclarations` in `checker.ts` as proposed by @sandersn --- 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 4395e852ebc..d6df79e3bbc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15610,7 +15610,7 @@ namespace ts { } } else { - const isStatic = forEach(member.modifiers, m => m.kind === SyntaxKind.StaticKeyword); + const isStatic = getModifierFlags(member) & ModifierFlags.Static; const names = isStatic ? staticNames : instanceNames; const memberName = member.name && getPropertyNameForPropertyNameNode(member.name); From 3a9a136e515db9f0ef1bdd0839a6dc25f9dca171 Mon Sep 17 00:00:00 2001 From: Joel Day Date: Wed, 4 Jan 2017 15:56:16 -0800 Subject: [PATCH 055/175] Changes based on feedback. Whitespace cleanup. Switching back to protocol.ts and reenabling stripInternal. Marking internal symbols indirectly exported by dependencies of protocol.ts as internal. --- Gulpfile.ts | 2 +- Jakefile.js | 13 ++++++++----- src/server/editorServices.ts | 3 +++ src/server/project.ts | 2 ++ src/server/session.ts | 24 ++++++++++++++++++++++++ src/server/tsconfig.library.json | 7 ++----- src/server/types.ts | 1 + 7 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 22bf020a435..ef65454bc23 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -473,7 +473,7 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { .pipe(gulp.dest(".")), dts.pipe(prependCopyright(/*outputCopyright*/true)) .pipe(insert.transform((content) => { - return content + "\r\nexport = ts;"; + return content + "\r\nexport = ts;\r\nexport as namespace ts;"; })) .pipe(gulp.dest(".")) ]); diff --git a/Jakefile.js b/Jakefile.js index b810477d861..093d6f16893 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -719,13 +719,16 @@ compileFile( [builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets), /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - { noOutFile: false, generateDeclarations: true }, - /*callback*/ function () { - + { noOutFile: false, generateDeclarations: true, stripInternal: true }, + /*callback*/ function () { prependFile(copyright, tsserverLibraryDefinitionFile); - // Appending 'export = ts;' at the end of the server library file to turn it into an external module - var tsserverLibraryDefinitionFileContents = fs.readFileSync(tsserverLibraryDefinitionFile).toString() + "\r\nexport = ts;"; + // Appending exports at the end of the server library + var tsserverLibraryDefinitionFileContents = + fs.readFileSync(tsserverLibraryDefinitionFile).toString() + + "\r\nexport = ts;" + + "\r\nexport as namespace ts;"; + fs.writeFileSync(tsserverLibraryDefinitionFile, tsserverLibraryDefinitionFileContents); }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 00df53e1e35..38873a38aba 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -293,6 +293,7 @@ namespace ts.server { this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); } + /* @internal */ getChangedFiles_TestOnly() { return this.changedFiles; } @@ -1274,6 +1275,7 @@ namespace ts.server { } } + /* @internal */ synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[] { const files: ProjectFilesWithTSDiagnostics[] = []; this.collectChanges(knownProjects, this.externalProjects, files); @@ -1282,6 +1284,7 @@ namespace ts.server { return files; } + /* @internal */ applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void { const recordChangedFiles = changedFiles && !openFiles && !closedFiles; if (openFiles) { diff --git a/src/server/project.ts b/src/server/project.ts index 6085ee05159..ff2dd582b89 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -58,6 +58,7 @@ namespace ts.server { return counts.ts === 0 && counts.tsx === 0; } + /* @internal */ export interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { projectErrors: Diagnostic[]; } @@ -593,6 +594,7 @@ namespace ts.server { return false; } + /* @internal */ getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics { this.updateGraph(); diff --git a/src/server/session.ts b/src/server/session.ts index 5c382aae7d3..b8eeb9219db 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -88,50 +88,65 @@ namespace ts.server { export namespace CommandNames { export const Brace: protocol.CommandTypes.Brace = "brace"; + /* @internal */ export const BraceFull: protocol.CommandTypes.BraceFull = "brace-full"; export const BraceCompletion: protocol.CommandTypes.BraceCompletion = "braceCompletion"; export const Change: protocol.CommandTypes.Change = "change"; export const Close: protocol.CommandTypes.Close = "close"; export const Completions: protocol.CommandTypes.Completions = "completions"; + /* @internal */ export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full"; export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails"; export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; export const Configure: protocol.CommandTypes.Configure = "configure"; export const Definition: protocol.CommandTypes.Definition = "definition"; + /* @internal */ export const DefinitionFull: protocol.CommandTypes.DefinitionFull = "definition-full"; export const Exit: protocol.CommandTypes.Exit = "exit"; export const Format: protocol.CommandTypes.Format = "format"; export const Formatonkey: protocol.CommandTypes.Formatonkey = "formatonkey"; + /* @internal */ export const FormatFull: protocol.CommandTypes.FormatFull = "format-full"; + /* @internal */ export const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull = "formatonkey-full"; + /* @internal */ export const FormatRangeFull: protocol.CommandTypes.FormatRangeFull = "formatRange-full"; export const Geterr: protocol.CommandTypes.Geterr = "geterr"; export const GeterrForProject: protocol.CommandTypes.GeterrForProject = "geterrForProject"; export const Implementation: protocol.CommandTypes.Implementation = "implementation"; + /* @internal */ export const ImplementationFull: protocol.CommandTypes.ImplementationFull = "implementation-full"; export const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; export const NavBar: protocol.CommandTypes.NavBar = "navbar"; + /* @internal */ export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full"; export const NavTree: protocol.CommandTypes.NavTree = "navtree"; export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full"; export const Navto: protocol.CommandTypes.Navto = "navto"; + /* @internal */ export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full"; export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences"; export const DocumentHighlights: protocol.CommandTypes.DocumentHighlights = "documentHighlights"; + /* @internal */ export const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull = "documentHighlights-full"; export const Open: protocol.CommandTypes.Open = "open"; export const Quickinfo: protocol.CommandTypes.Quickinfo = "quickinfo"; + /* @internal */ export const QuickinfoFull: protocol.CommandTypes.QuickinfoFull = "quickinfo-full"; export const References: protocol.CommandTypes.References = "references"; + /* @internal */ export const ReferencesFull: protocol.CommandTypes.ReferencesFull = "references-full"; export const Reload: protocol.CommandTypes.Reload = "reload"; export const Rename: protocol.CommandTypes.Rename = "rename"; + /* @internal */ export const RenameInfoFull: protocol.CommandTypes.RenameInfoFull = "rename-full"; + /* @internal */ export const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull = "renameLocations-full"; export const Saveto: protocol.CommandTypes.Saveto = "saveto"; export const SignatureHelp: protocol.CommandTypes.SignatureHelp = "signatureHelp"; + /* @internal */ export const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull = "signatureHelp-full"; export const TypeDefinition: protocol.CommandTypes.TypeDefinition = "typeDefinition"; export const ProjectInfo: protocol.CommandTypes.ProjectInfo = "projectInfo"; @@ -140,19 +155,28 @@ namespace ts.server { export const OpenExternalProject: protocol.CommandTypes.OpenExternalProject = "openExternalProject"; export const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects = "openExternalProjects"; export const CloseExternalProject: protocol.CommandTypes.CloseExternalProject = "closeExternalProject"; + /* @internal */ export const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList = "synchronizeProjectList"; + /* @internal */ export const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + /* @internal */ export const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + /* @internal */ export const Cleanup: protocol.CommandTypes.Cleanup = "cleanup"; + /* @internal */ export const OutliningSpans: protocol.CommandTypes.OutliningSpans = "outliningSpans"; export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments"; export const Indentation: protocol.CommandTypes.Indentation = "indentation"; export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate"; + /* @internal */ export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + /* @internal */ export const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + /* @internal */ export const BreakpointStatement: protocol.CommandTypes.BreakpointStatement = "breakpointStatement"; export const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; export const GetCodeFixes: protocol.CommandTypes.GetCodeFixes = "getCodeFixes"; + /* @internal */ export const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull = "getCodeFixes-full"; export const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes = "getSupportedCodeFixes"; } diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 397211e6ff4..76d700dd291 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -2,14 +2,11 @@ "compilerOptions": { "noImplicitAny": true, "noImplicitThis": true, - "removeComments": false, "preserveConstEnums": true, "pretty": true, "outFile": "../../built/local/tsserverlibrary.js", "sourceMap": true, - "types": [ - "node" - ], + "stripInternal": true, "target": "es5", "noUnusedLocals": true, "noUnusedParameters": true, @@ -19,7 +16,7 @@ "editorServices.ts", "lsHost.ts", "project.ts", - "protocol.d.ts", + "protocol.ts", "scriptInfo.ts", "scriptVersionCache.ts", "session.ts", diff --git a/src/server/types.ts b/src/server/types.ts index 9f53fa8def1..2c18f275202 100644 --- a/src/server/types.ts +++ b/src/server/types.ts @@ -82,6 +82,7 @@ declare namespace ts.server { readonly installSuccess: boolean; } + /* @internal */ export interface InstallTypingHost extends JsTyping.TypingResolutionHost { writeFile(path: string, content: string): void; createDirectory(path: string): void; From 4086bd13c7b459ab4302c48fc3ac428cc2078e08 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 5 Jan 2017 11:01:12 -0800 Subject: [PATCH 056/175] Update LKG --- lib/lib.d.ts | 3 +- lib/lib.es5.d.ts | 3 +- lib/lib.es6.d.ts | 3 +- lib/protocol.d.ts | 2 + lib/tsc.js | 4848 +++++++++++++---------- lib/tsserver.js | 6730 +++++++++++++++++-------------- lib/tsserverlibrary.d.ts | 369 +- lib/tsserverlibrary.js | 6725 +++++++++++++++++-------------- lib/typescript.d.ts | 255 +- lib/typescript.js | 7491 ++++++++++++++++++++--------------- lib/typescriptServices.d.ts | 255 +- lib/typescriptServices.js | 7491 ++++++++++++++++++++--------------- lib/typingsInstaller.js | 396 +- 13 files changed, 19912 insertions(+), 14659 deletions(-) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 5b1f3d7c393..6a4e8ec5216 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -1191,8 +1191,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 4d48fed85ed..2ce9151e289 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -1191,8 +1191,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 9530bf7bfbc..1c5224c0cc8 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -1191,8 +1191,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index f3737c76c46..d6c0246af34 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1722,12 +1722,14 @@ declare namespace ts.server.protocol { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } diff --git a/lib/tsc.js b/lib/tsc.js index 840e832f3bf..c1ab6d062f5 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -201,7 +201,7 @@ var ts; ts.toPath = toPath; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -220,7 +220,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -230,7 +230,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -240,7 +240,7 @@ var ts; } ts.find = find; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -263,7 +263,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -273,7 +273,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -976,6 +976,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2470,7 +2471,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -2627,6 +2628,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2856,6 +2858,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2865,6 +2869,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2916,6 +2921,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -3084,6 +3091,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3097,10 +3105,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -3149,6 +3157,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3205,22 +3215,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3601,7 +3614,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3787,7 +3800,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -4891,7 +4904,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { + while (node && node.kind !== 262) { node = node.parent; } return node; @@ -4899,11 +4912,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: return true; } return false; @@ -4968,18 +4981,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 292 && node._children.length > 0) { + if (node.kind === 293 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; + return node.kind >= 263 && node.kind <= 289; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; + return node.kind >= 279 && node.kind <= 292; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -5073,11 +5086,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; + return node.kind === 224 && node.parent.kind === 257; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 && + return node && node.kind === 231 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -5086,11 +5099,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); + return node.kind === 231 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || + return node.kind === 262 || + node.kind === 231 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5103,9 +5116,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261: + case 262: return ts.isExternalModule(node.parent); - case 231: + case 232: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5117,22 +5130,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261: - case 232: - case 256: - case 230: - case 211: + case 262: + case 233: + case 257: + case 231: case 212: case 213: + case 214: case 150: case 149: case 151: case 152: - case 225: + case 226: case 184: case 185: return true; - case 204: + case 205: return parentNode && !isFunctionLike(parentNode); } return false; @@ -5210,7 +5223,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { + if (node.body && node.body.kind === 205) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5222,26 +5235,26 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261: + case 262: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 223: + case 224: case 174: - case 226: - case 197: case 227: + case 197: + case 228: + case 231: case 230: - case 229: - case 260: - case 225: + case 261: + case 226: case 184: case 149: case 151: case 152: - case 228: + case 229: errorNode = node.name; break; case 185: @@ -5265,7 +5278,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); + return node.kind === 230 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5282,7 +5295,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 + return node.kind === 208 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -5354,9 +5367,9 @@ var ts; case 147: case 146: case 144: - case 223: + case 224: return node === parent_1.type; - case 225: + case 226: case 184: case 185: case 150: @@ -5381,27 +5394,41 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216: + case 217: return visitor(node); - case 232: - case 204: - case 208: + case 233: + case 205: case 209: case 210: case 211: case 212: case 213: - case 217: + case 214: case 218: - case 253: - case 254: case 219: - case 221: - case 256: + case 254: + case 255: + case 220: + case 222: + case 257: return ts.forEachChild(node, traverse); } } @@ -5417,11 +5444,11 @@ var ts; if (operand) { traverse(operand); } - case 229: - case 227: case 230: case 228: - case 226: + case 231: + case 229: + case 227: case 197: return; default: @@ -5455,13 +5482,13 @@ var ts; if (node) { switch (node.kind) { case 174: - case 260: + case 261: case 144: - case 257: + case 258: case 147: case 146: - case 258: - case 223: + case 259: + case 224: return true; } } @@ -5473,7 +5500,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); + return node && (node.kind === 227 || node.kind === 197); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5484,7 +5511,7 @@ var ts; switch (kind) { case 150: case 184: - case 225: + case 226: case 185: case 149: case 148: @@ -5507,7 +5534,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: return true; } @@ -5516,20 +5543,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return true; - case 219: + case 220: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); + return node && node.kind === 205 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -5593,9 +5632,9 @@ var ts; if (!includeArrowFunctions) { continue; } - case 225: + case 226: case 184: - case 230: + case 231: case 147: case 146: case 149: @@ -5606,13 +5645,26 @@ var ts; case 153: case 154: case 155: - case 229: - case 261: + case 230: + case 262: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 150: + case 226: + case 184: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -5623,7 +5675,7 @@ var ts; case 142: node = node.parent; break; - case 225: + case 226: case 184: case 185: if (!stopOnFunctions) { @@ -5672,7 +5724,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157: - case 272: + case 273: return node.typeName; case 199: return isEntityNameExpression(node.expression) @@ -5706,21 +5758,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226: + case 227: return true; case 147: - return node.parent.kind === 226; + return node.parent.kind === 227; case 151: case 152: case 149: return node.body !== undefined - && node.parent.kind === 226; + && node.parent.kind === 227; case 144: return node.parent.body !== undefined && (node.parent.kind === 150 || node.parent.kind === 149 || node.parent.kind === 152) - && node.parent.parent.kind === 226; + && node.parent.parent.kind === 227; } return false; } @@ -5736,7 +5788,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226: + case 227: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149: case 152: @@ -5746,9 +5798,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { + if (parent.kind === 249 || + parent.kind === 248 || + parent.kind === 250) { return parent.tagName === node; } return false; @@ -5787,10 +5839,11 @@ var ts; case 194: case 12: case 198: - case 246: case 247: + case 248: case 195: case 189: + case 202: return true; case 141: while (node.parent.kind === 141) { @@ -5806,46 +5859,46 @@ var ts; case 98: var parent_3 = node.parent; switch (parent_3.kind) { - case 223: + case 224: case 144: case 147: case 146: - case 260: - case 257: + case 261: + case 258: case 174: return parent_3.initializer === node; - case 207: case 208: case 209: case 210: - case 216: + case 211: case 217: case 218: - case 253: - case 220: - case 218: + case 219: + case 254: + case 221: + case 219: return parent_3.expression === node; - case 211: + case 212: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || forStatement.condition === node || forStatement.incrementor === node; - case 212: case 213: + case 214: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || forInStatement.expression === node; case 182: case 200: return node === parent_3.expression; - case 202: + case 203: return node === parent_3.expression; case 142: return node === parent_3.expression; case 145: + case 253: case 252: - case 251: - case 259: + case 260: return true; case 199: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); @@ -5865,7 +5918,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; + return node.kind === 235 && node.moduleReference.kind === 246; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5874,7 +5927,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; + return node.kind === 235 && node.moduleReference.kind !== 246; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5898,7 +5951,7 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184; } @@ -5945,35 +5998,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235) { + if (node.kind === 236) { return node.moduleSpecifier; } - if (node.kind === 234) { + if (node.kind === 235) { var reference = node.moduleReference; - if (reference.kind === 245) { + if (reference.kind === 246) { return reference.expression; } } - if (node.kind === 241) { + if (node.kind === 242) { return node.moduleSpecifier; } - if (node.kind === 230 && node.name.kind === 9) { + if (node.kind === 231 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 + return node.kind === 236 && node.importClause && !!node.importClause.name; } @@ -5984,8 +6037,8 @@ var ts; case 144: case 149: case 148: + case 259: case 258: - case 257: case 147: case 146: return node.questionToken !== undefined; @@ -5995,9 +6048,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 && + return node.kind === 275 && node.parameters.length > 0 && - node.parameters[0].type.kind === 276; + node.parameters[0].type.kind === 277; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -6010,7 +6063,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281) { + if (doc.kind === 282) { if (doc.kind === kind) { result.push(doc); } @@ -6036,9 +6089,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205; + parent.parent.parent.kind === 206; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; + parent.parent.kind === 206; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -6048,13 +6101,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 && parent.operatorToken.kind === 57 && - parent.parent.kind === 207; + parent.parent.kind === 208; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; + var isModuleDeclaration = node.kind === 231 && + parent && parent.kind === 231; + var isPropertyAssignmentExpression = parent && parent.kind === 258; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -6072,17 +6125,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281); + var tags = getJSDocTags(func, 282); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_6; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_6; }); } else { return undefined; @@ -6090,7 +6143,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); + var tag = getFirstJSDocTag(node, 284); if (!tag && node.kind === 144) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -6101,15 +6154,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); + return getFirstJSDocTag(node, 281); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); + return getFirstJSDocTag(node, 283); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -6122,8 +6175,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { + if (node.type && node.type.kind === 276 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { return true; } } @@ -6147,19 +6200,19 @@ var ts; case 191: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: case 213: + case 214: return parent.initializer === node ? 1 : 0; case 183: case 175: case 196: node = parent; break; - case 258: + case 259: if (parent.name !== node) { return 0; } - case 257: + case 258: node = parent.parent; break; default: @@ -6173,6 +6226,17 @@ var ts; return getAssignmentTargetKind(node) !== 0; } ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 177 && node.kind !== 178) { + return false; + } + node = node.parent; + while (node && node.kind === 183) { + node = node.parent; + } + return node && node.kind === 186; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -6184,7 +6248,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -6197,7 +6261,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { + if (parent.kind === 240 || parent.kind === 244) { if (parent.propertyName) { return true; } @@ -6223,8 +6287,8 @@ var ts; case 148: case 151: case 152: - case 260: - case 257: + case 261: + case 258: case 177: return parent.name === node; case 141: @@ -6236,22 +6300,22 @@ var ts; } return false; case 174: - case 239: + case 240: return parent.propertyName === node; - case 243: + case 244: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || - node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); + return node.kind === 235 || + node.kind === 234 || + node.kind === 237 && !!node.name || + node.kind === 238 || + node.kind === 240 || + node.kind === 244 || + node.kind === 241 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -6431,13 +6495,13 @@ var ts; var kind = node.kind; return kind === 150 || kind === 184 - || kind === 225 + || kind === 226 || kind === 185 || kind === 149 || kind === 151 || kind === 152 - || kind === 230 - || kind === 261; + || kind === 231 + || kind === 262; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -6559,14 +6623,13 @@ var ts; case 184: case 185: case 197: - case 246: case 247: + case 248: case 11: case 12: case 194: case 183: case 198: - case 297: return 19; case 181: case 177: @@ -6740,13 +6803,12 @@ var ts; "\u0085": "\\u0085" }); function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -7622,8 +7684,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229: case 230: + case 231: return parseNode === parseNode.parent.name; } } @@ -7641,7 +7703,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { + if (declaration.kind === 227 && declaration !== node) { return true; } } @@ -7692,6 +7754,10 @@ var ts; return node.kind === 70; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { return isIdentifier(node) && node.autoGenerateKind > 0; } @@ -7759,18 +7825,18 @@ var ts; || kind === 151 || kind === 152 || kind === 155 - || kind === 203; + || kind === 204; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 - || kind === 258 + return kind === 258 || kind === 259 + || kind === 260 || kind === 149 || kind === 151 || kind === 152 - || kind === 244; + || kind === 245; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { @@ -7823,7 +7889,7 @@ var ts; ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223: + case 224: case 144: case 174: return true; @@ -7901,8 +7967,8 @@ var ts; || kind === 178 || kind === 180 || kind === 179 - || kind === 246 || kind === 247 + || kind === 248 || kind === 181 || kind === 175 || kind === 183 @@ -7921,7 +7987,7 @@ var ts; || kind === 100 || kind === 96 || kind === 201 - || kind === 297; + || kind === 202; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -7949,7 +8015,6 @@ var ts; || kind === 196 || kind === 200 || kind === 198 - || kind === 297 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -7963,11 +8028,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294; + return node.kind === 295; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293; + return node.kind === 294; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -7980,11 +8045,11 @@ var ts; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 202; + return node.kind === 203; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 204; + return node.kind === 205; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -8002,121 +8067,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223; + return node.kind === 224; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224; + return node.kind === 225; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232; + return node.kind === 233; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 - || kind === 230; + return kind === 232 + || kind === 231; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 - || kind === 237; + return kind === 239 + || kind === 238; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239; + return node.kind === 240; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242; + return node.kind === 243; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243; + return node.kind === 244; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 231 || node.kind === 230; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 || kind === 174 - || kind === 226 + || kind === 227 || kind === 197 || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 + || kind === 230 + || kind === 261 + || kind === 244 + || kind === 226 || kind === 184 || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 + || kind === 237 + || kind === 235 + || kind === 240 + || kind === 228 || kind === 149 || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 + || kind === 231 + || kind === 234 + || kind === 238 || kind === 144 - || kind === 257 + || kind === 258 || kind === 147 || kind === 146 || kind === 152 - || kind === 258 - || kind === 228 + || kind === 259 + || kind === 229 || kind === 143 - || kind === 223 - || kind === 285; + || kind === 224 + || kind === 286; } function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 + return kind === 226 + || kind === 245 || kind === 227 || kind === 228 || kind === 229 || kind === 230 + || kind === 231 + || kind === 236 || kind === 235 - || kind === 234 + || kind === 242 || kind === 241 - || kind === 240 - || kind === 233; + || kind === 234; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 - || kind === 216 - || kind === 218 - || kind === 220 - || kind === 221 - || kind === 205 + return kind === 216 + || kind === 215 + || kind === 223 || kind === 210 + || kind === 208 + || kind === 207 + || kind === 213 + || kind === 214 + || kind === 212 + || kind === 209 + || kind === 220 || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; + || kind === 219 + || kind === 221 + || kind === 222 + || kind === 206 + || kind === 211 + || kind === 218 + || kind === 294 + || kind === 297 + || kind === 296; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -8134,22 +8199,22 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204; + || kind === 205; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 245 + return kind === 246 || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 248; + return node.kind === 249; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249; + return node.kind === 250; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -8161,60 +8226,60 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 + return kind === 247 + || kind === 253 + || kind === 248 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 - || kind === 251; + return kind === 251 + || kind === 252; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 252; + || kind === 253; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 - || kind === 254; + return kind === 254 + || kind === 255; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255; + return node.kind === 256; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256; + return node.kind === 257; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 257; + return node.kind === 258; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 261; + return node.kind === 262; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -8355,7 +8420,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { return current; } } @@ -8375,14 +8440,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= ts.getModifierFlags(node); } return flags; @@ -8391,14 +8456,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= node.flags; } return flags; @@ -8457,7 +8522,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 + var ConstructorForKind = kind === 262 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -9153,7 +9218,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + var node = createNode(203, location); node.expression = expression; node.literal = literal; return node; @@ -9167,7 +9232,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + var block = createNode(205, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -9183,7 +9248,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + var node = createNode(206, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -9198,7 +9263,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + var node = createNode(225, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -9211,7 +9276,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); + var node = createNode(224, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -9226,11 +9291,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206, location); + return createNode(207, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); + var node = createNode(208, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -9243,7 +9308,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -9258,7 +9323,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209, location); + var node = createNode(210, location); node.statement = statement; node.expression = expression; return node; @@ -9272,7 +9337,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210, location); + var node = createNode(211, location); node.expression = expression; node.statement = statement; return node; @@ -9286,7 +9351,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + var node = createNode(212, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -9302,7 +9367,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9317,7 +9382,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9332,7 +9397,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -9347,7 +9412,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215, location); + var node = createNode(216, location); if (label) { node.label = label; } @@ -9362,7 +9427,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.expression = expression; return node; } @@ -9375,7 +9440,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217, location); + var node = createNode(218, location); node.expression = expression; node.statement = statement; return node; @@ -9389,7 +9454,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); + var node = createNode(219, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -9403,7 +9468,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219, location); + var node = createNode(220, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -9417,7 +9482,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220, location); + var node = createNode(221, location); node.expression = expression; return node; } @@ -9430,7 +9495,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -9445,7 +9510,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.clauses = createNodeArray(clauses); return node; } @@ -9458,7 +9523,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); + var node = createNode(226, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -9478,7 +9543,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); + var node = createNode(227, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -9496,7 +9561,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -9512,7 +9577,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -9526,7 +9591,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.name = name; return node; } @@ -9539,7 +9604,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.elements = createNodeArray(elements); return node; } @@ -9552,7 +9617,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + var node = createNode(240, location); node.propertyName = propertyName; node.name = name; return node; @@ -9566,7 +9631,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -9582,7 +9647,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -9598,7 +9663,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.elements = createNodeArray(elements); return node; } @@ -9611,7 +9676,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -9625,7 +9690,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + var node = createNode(247, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -9640,7 +9705,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9654,7 +9719,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + var node = createNode(249, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9668,7 +9733,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + var node = createNode(250, location); node.tagName = tagName; return node; } @@ -9681,7 +9746,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + var node = createNode(251, location); node.name = name; node.initializer = initializer; return node; @@ -9695,7 +9760,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -9707,21 +9772,22 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(255, location); + var node = createNode(256, location); node.token = token; node.types = createNodeArray(types); return node; @@ -9735,7 +9801,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253, location); + var node = createNode(254, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -9749,7 +9815,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254, location); + var node = createNode(255, location); node.statements = createNodeArray(statements); return node; } @@ -9762,7 +9828,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + var node = createNode(257, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -9776,7 +9842,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); + var node = createNode(258, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -9791,14 +9857,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); + var node = createNode(259, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259, location); + var node = createNode(260, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -9819,7 +9885,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createNode(262, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -9879,27 +9945,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createNode(294, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createNode(297); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createNode(296); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + var node = createNode(295, location || original); node.expression = expression; node.original = original; return node; @@ -9912,12 +9978,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; function createComma(left, right) { return createBinary(left, 25, right); } @@ -10081,6 +10141,19 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -10180,9 +10253,9 @@ var ts; case 151: case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); case 258: + return createExpressionForPropertyAssignment(property, receiver); + case 259: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149: return createExpressionForMethodDeclaration(property, receiver); @@ -10540,7 +10613,7 @@ var ts; case 177: node = node.expression; continue; - case 294: + case 295: node = node.expression; continue; } @@ -10588,7 +10661,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { + while (node.kind === 295) { node = node.expression; } return node; @@ -10648,7 +10721,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 262) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -10839,10 +10912,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { + if (node.kind === 236 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { + if (node.kind === 242 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -10906,11 +10979,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 258: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 259: + return bindingElement.name; + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -10930,7 +11003,7 @@ var ts; case 174: return bindingElement.dotDotDotToken; case 196: - case 259: + case 260: return bindingElement; } return undefined; @@ -10946,7 +11019,7 @@ var ts; : propertyName; } break; - case 257: + case 258: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -10954,7 +11027,7 @@ var ts; : propertyName; } break; - case 259: + case 260: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -11059,15 +11132,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 236: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 235: + if (node.moduleReference.kind === 246) { externalImports.push(node); } break; - case 241: + case 242: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -11094,12 +11167,12 @@ var ts; } } break; - case 240: + case 241: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 206: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -11107,7 +11180,7 @@ var ts; } } break; - case 225: + case 226: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -11125,7 +11198,7 @@ var ts; } } break; - case 226: + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -11173,7 +11246,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 262) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { @@ -11222,20 +11295,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259: + case 260: return visitNode(cbNode, node.expression); case 144: case 147: case 146: - case 257: - case 223: + case 258: + case 224: case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -11261,7 +11334,7 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -11353,6 +11426,8 @@ var ts; visitNode(cbNode, node.type); case 201: return visitNode(cbNode, node.expression); + case 202: + return visitNode(cbNode, node.name); case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -11361,84 +11436,77 @@ var ts; visitNode(cbNode, node.whenFalse); case 196: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 205: + case 232: return visitNodes(cbNodes, node.statements); - case 261: + case 262: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 206: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 225: return visitNodes(cbNodes, node.declarations); - case 207: - return visitNode(cbNode, node.expression); case 208: + return visitNode(cbNode, node.expression); + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 210: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 211: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 212: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + case 216: + return visitNode(cbNode, node.label); + case 217: + return visitNode(cbNode, node.expression); case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232: + case 233: return visitNodes(cbNodes, node.clauses); - case 253: + case 254: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254: + case 255: return visitNodes(cbNodes, node.statements); - case 219: + case 220: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220: - return visitNode(cbNode, node.expression); case 221: + return visitNode(cbNode, node.expression); + case 222: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 257: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145: return visitNode(cbNode, node.expression); - case 226: - case 197: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 227: + case 197: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -11450,143 +11518,151 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 261: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 237: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: - return visitNode(cbNode, node.name); - case 237: + case 234: return visitNode(cbNode, node.name); case 238: - case 242: + return visitNode(cbNode, node.name); + case 239: + case 243: return visitNodes(cbNodes, node.elements); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 240: + case 244: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 203: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142: return visitNode(cbNode, node.expression); - case 255: + case 256: return visitNodes(cbNodes, node.types); case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: - return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNode(cbNode, node.expression); + case 245: + return visitNodes(cbNodes, node.decorators); + case 247: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: case 248: + case 249: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250: + case 251: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251: - return visitNode(cbNode, node.expression); case 252: return visitNode(cbNode, node.expression); - case 249: + case 253: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250: return visitNode(cbNode, node.tagName); - case 262: + case 263: return visitNode(cbNode, node.type); - case 266: - return visitNodes(cbNodes, node.types); case 267: return visitNodes(cbNodes, node.types); - case 265: + case 268: + return visitNodes(cbNodes, node.types); + case 266: return visitNode(cbNode, node.elementType); + case 270: + return visitNode(cbNode, node.type); case 269: return visitNode(cbNode, node.type); - case 268: - return visitNode(cbNode, node.type); - case 270: + case 271: return visitNode(cbNode, node.literal); - case 272: + case 273: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273: - return visitNode(cbNode, node.type); case 274: + return visitNode(cbNode, node.type); + case 275: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); case 276: return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNode(cbNode, node.type); + case 272: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 279: return visitNodes(cbNodes, node.tags); - case 281: + case 282: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: - return visitNode(cbNode, node.typeExpression); case 283: return visitNode(cbNode, node.typeExpression); - case 280: - return visitNode(cbNode, node.typeExpression); case 284: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 281: + return visitNode(cbNode, node.typeExpression); case 285: + return visitNodes(cbNodes, node.typeParameters); + case 286: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 288: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 287: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 295: return visitNode(cbNode, node.expression); - case 288: + case 289: return visitNode(cbNode, node.literal); } } @@ -11750,7 +11826,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -12369,7 +12445,7 @@ var ts; case 151: case 152: case 147: - case 203: + case 204: return true; case 149: var methodDeclaration = node; @@ -12383,8 +12459,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: case 254: + case 255: return true; } } @@ -12393,42 +12469,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: + case 226: + case 206: case 205: - case 204: + case 209: case 208: - case 207: - case 220: + case 221: + case 217: + case 219: case 216: - case 218: case 215: + case 213: case 214: case 212: - case 213: case 211: - case 210: - case 217: - case 206: - case 221: - case 219: - case 209: + case 218: + case 207: case 222: + case 220: + case 210: + case 223: + case 236: case 235: - case 234: + case 242: case 241: - case 240: - case 230: - case 226: + case 231: case 227: - case 229: case 228: + case 230: + case 229: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } function isReusableTypeMember(node) { if (node) { @@ -12444,7 +12520,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 224) { return false; } var variableDeclarator = node; @@ -12576,7 +12652,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(203); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -13701,8 +13777,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 249) { + var node = createNode(247, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -13712,7 +13788,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 248); result = opening; } if (inExpressionContext && token() === 26) { @@ -13772,7 +13848,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(249, fullStart); scanJsxText(); } else { @@ -13784,7 +13860,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(248, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -13803,9 +13879,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(253); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -13822,7 +13899,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(251); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -13837,7 +13914,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(252); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -13845,7 +13922,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(250); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -14062,7 +14139,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(260, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -14081,7 +14158,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(259, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -14092,7 +14169,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(258, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -14138,8 +14215,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(202, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -14148,7 +14232,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(205); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14179,12 +14263,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(207); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14194,7 +14278,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -14205,7 +14289,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14228,21 +14312,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(213, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + var forOfStatement = createNode(214, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(212, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -14260,7 +14344,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 216 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -14268,7 +14352,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -14277,7 +14361,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14286,7 +14370,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(254); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -14294,7 +14378,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(255); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -14304,12 +14388,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(233, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -14317,14 +14401,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(221); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -14335,7 +14419,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(257); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -14345,7 +14429,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -14354,13 +14438,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(220, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(208, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -14512,9 +14596,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); - case 71: return parseBreakOrContinueStatement(215); + case 71: + return parseBreakOrContinueStatement(216); case 95: return parseReturnStatement(); case 106: @@ -14593,7 +14677,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -14665,7 +14749,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(224); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -14674,7 +14758,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(225); switch (token()) { case 103: break; @@ -14703,7 +14787,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -14711,7 +14795,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -14896,7 +14980,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(204); nextToken(); return finishNode(result); } @@ -14930,7 +15014,7 @@ var ts; return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -14965,7 +15049,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(256); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -14988,7 +15072,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -14999,7 +15083,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136); @@ -15011,13 +15095,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(261, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -15032,7 +15116,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(232, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -15043,7 +15127,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -15055,7 +15139,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139) { @@ -15100,7 +15184,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(234, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -15116,7 +15200,7 @@ var ts; if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + var importEqualsDeclaration = createNode(235, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -15126,7 +15210,7 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(236, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || @@ -15140,13 +15224,13 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(237, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); } return finishNode(importClause); } @@ -15156,7 +15240,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(246); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -15174,7 +15258,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(238); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -15182,14 +15266,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(244); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(240); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -15208,13 +15292,13 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 240 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { @@ -15222,7 +15306,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); + node.exportClause = parseNamedImportsOrExports(243); if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); @@ -15232,7 +15316,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(241, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -15311,10 +15395,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 + || node.kind === 235 && node.moduleReference.kind === 246 + || node.kind === 236 || node.kind === 241 + || node.kind === 242 ? node : undefined; }); @@ -15350,7 +15434,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(263, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -15361,12 +15445,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(267, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(274, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -15377,20 +15461,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(266, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(269, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(270, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -15442,27 +15526,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(278); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(276); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(275); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -15483,7 +15567,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(273); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -15523,18 +15607,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(271); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(270); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(268); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -15548,7 +15632,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(267); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -15564,12 +15648,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(264); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(289); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -15582,11 +15666,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(265, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(269, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -15730,7 +15814,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(279, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -15840,7 +15924,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -15895,7 +15979,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -15906,20 +15990,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -15934,7 +16018,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -15943,7 +16027,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -15952,7 +16036,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(286, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -15966,7 +16050,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 273) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { var name_14 = jsDocTypeReference.name; @@ -15984,7 +16068,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -16025,7 +16109,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(231, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -16069,7 +16153,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); @@ -16092,7 +16176,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -16384,7 +16468,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -16411,16 +16495,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 228 || node.kind === 229) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 232) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -16436,7 +16520,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 231) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -16545,7 +16629,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { symbol.valueDeclaration = node; } } @@ -16576,9 +16660,9 @@ var ts; return "__new"; case 155: return "__index"; - case 241: + case 242: return "__export"; - case 240: + case 241: return node.isExportEquals ? "export=" : "default"; case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -16592,20 +16676,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: case 226: + case 227: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 275: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144: - ts.Debug.assert(node.parent.kind === 274); + ts.Debug.assert(node.parent.kind === 275); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 286: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -16649,7 +16733,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -16669,7 +16753,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -16677,7 +16761,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -16738,7 +16822,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 262) { node.flags |= emitFlags; } if (isIIFE) { @@ -16814,43 +16898,43 @@ var ts; return; } switch (node.kind) { - case 210: + case 211: bindWhileStatement(node); break; - case 209: + case 210: bindDoStatement(node); break; - case 211: + case 212: bindForStatement(node); break; - case 212: case 213: + case 214: bindForInOrForOfStatement(node); break; - case 208: + case 209: bindIfStatement(node); break; - case 216: - case 220: + case 217: + case 221: bindReturnOrThrow(node); break; + case 216: case 215: - case 214: bindBreakOrContinueStatement(node); break; - case 221: + case 222: bindTryStatement(node); break; - case 218: + case 219: bindSwitchStatement(node); break; - case 232: + case 233: bindCaseBlock(node); break; - case 253: + case 254: bindCaseClause(node); break; - case 219: + case 220: bindLabeledStatement(node); break; case 190: @@ -16868,7 +16952,7 @@ var ts; case 193: bindConditionalExpressionFlow(node); break; - case 223: + case 224: bindVariableDeclarationFlow(node); break; case 179: @@ -17034,11 +17118,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: - case 210: case 209: - return parent.expression === node; case 211: + case 210: + return parent.expression === node; + case 212: case 193: return parent.condition === node; } @@ -17102,7 +17186,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 220 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -17137,7 +17221,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 225) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -17159,7 +17243,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 217) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -17179,7 +17263,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -17236,7 +17320,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -17301,7 +17385,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 210) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } @@ -17332,13 +17416,13 @@ var ts; else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 258) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 259) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 260) { bindAssignmentTargetFlow(p.expression); } } @@ -17438,7 +17522,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { bindInitializedVariableFlow(node); } } @@ -17465,28 +17549,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197: - case 226: - case 229: + case 227: + case 230: case 176: case 161: - case 287: - case 270: + case 288: + case 271: return 1; - case 227: - return 1 | 64; - case 274: - case 230: case 228: + return 1 | 64; + case 275: + case 231: + case 229: case 170: return 1 | 32; - case 261: + case 262: return 1 | 4 | 32; case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } case 150: - case 225: + case 226: case 148: case 151: case 152: @@ -17499,17 +17583,17 @@ var ts; case 184: case 185: return 1 | 4 | 32 | 8 | 16; - case 231: + case 232: return 4; case 147: return node.initializer ? 4 : 0; - case 256: - case 211: + case 257: case 212: case 213: - case 232: + case 214: + case 233: return 2; - case 204: + case 205: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -17525,20 +17609,20 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 231: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 262: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197: - case 226: + case 227: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 230: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161: case 176: - case 227: - case 270: - case 287: + case 228: + case 271: + case 288: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 158: case 159: @@ -17550,11 +17634,11 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 274: - case 228: + case 275: + case 229: case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -17570,11 +17654,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 262 ? node : node.body; + if (body && (body.kind === 262 || body.kind === 232)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 242 || stat.kind === 241) { return true; } } @@ -17650,11 +17734,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 260 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -17676,10 +17760,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 231: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 262: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -17769,8 +17853,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 262 && + blockScopeContainer.kind !== 231 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -17853,14 +17937,14 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 286) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -17892,7 +17976,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 257: return checkStrictModeCatchClause(node); case 186: return checkStrictModeDeleteExpression(node); @@ -17902,7 +17986,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 218: return checkStrictModeWithStatement(node); case 167: seenThisKeyword = true; @@ -17913,22 +17997,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: return bindParameter(node); - case 223: + case 224: case 174: return bindVariableDeclarationOrBindingElement(node); case 147: case 146: - case 271: + case 272: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 287: return bindJSDocProperty(node); - case 257: case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 260: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 259: - case 251: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 261: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 260: + case 252: var root = container; var hasRest = false; while (root.parent) { @@ -17949,7 +18033,7 @@ var ts; case 149: case 148: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: + case 226: return bindFunctionDeclaration(node); case 150: return declareSymbolAndAddToSymbolTable(node, 16384, 0); @@ -17959,12 +18043,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536, 74687); case 158: case 159: - case 274: + case 275: return bindFunctionOrConstructorType(node); case 161: case 170: - case 287: - case 270: + case 288: + case 271: return bindAnonymousDeclaration(node, 2048, "__type"); case 176: return bindObjectLiteralExpression(node); @@ -17977,43 +18061,43 @@ var ts; } break; case 197: - case 226: + case 227: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 228: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 286: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); case 229: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 230: + return bindEnumDeclaration(node); + case 231: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); - case 236: - return bindImportClause(node); - case 241: - return bindExportDeclaration(node); + case 235: + case 238: case 240: + case 244: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 234: + return bindNamespaceExportDeclaration(node); + case 237: + return bindImportClause(node); + case 242: + return bindExportDeclaration(node); + case 241: return bindExportAssignment(node); - case 261: + case 262: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 205: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 232: return updateStrictModeStatementList(node.statements); } } @@ -18041,7 +18125,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -18051,7 +18135,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 262) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -18100,7 +18184,7 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 226 || container.kind === 184) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } @@ -18136,7 +18220,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 227) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -18246,15 +18330,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || + node.kind === 227 || + (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 206 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -18272,13 +18356,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180: return computeNewExpression(node, subtreeFlags); - case 230: + case 231: return computeModuleDeclaration(node, subtreeFlags); case 183: return computeParenthesizedExpression(node, subtreeFlags); case 192: return computeBinaryExpression(node, subtreeFlags); - case 207: + case 208: return computeExpressionStatement(node, subtreeFlags); case 144: return computeParameter(node, subtreeFlags); @@ -18286,23 +18370,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184: return computeFunctionExpression(node, subtreeFlags); - case 225: - return computeFunctionDeclaration(node, subtreeFlags); - case 223: - return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeFunctionDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclarationList(node, subtreeFlags); + case 206: + return computeVariableStatement(node, subtreeFlags); + case 220: + return computeLabeledStatement(node, subtreeFlags); + case 227: return computeClassDeclaration(node, subtreeFlags); case 197: return computeClassExpression(node, subtreeFlags); - case 255: - return computeHeritageClause(node, subtreeFlags); case 256: + return computeHeritageClause(node, subtreeFlags); + case 257: return computeCatchClause(node, subtreeFlags); case 199: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -18315,7 +18399,7 @@ var ts; case 151: case 152: return computeAccessor(node, subtreeFlags); - case 234: + case 235: return computeImportEquals(node, subtreeFlags); case 177: return computePropertyAccess(node, subtreeFlags); @@ -18703,25 +18787,25 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: + case 230: + case 261: case 182: case 200: case 201: case 130: transformFlags |= 3; break; - case 246: case 247: case 248: - case 10: case 249: + case 10: case 250: case 251: case 252: + case 253: transformFlags |= 4; break; - case 213: + case 214: transformFlags |= 8; case 12: case 13: @@ -18729,8 +18813,9 @@ var ts; case 15: case 194: case 181: - case 258: + case 259: case 114: + case 202: transformFlags |= 192; break; case 195: @@ -18760,8 +18845,8 @@ var ts; case 164: case 165: case 166: - case 227: case 228: + case 229: case 167: case 168: case 169: @@ -18779,7 +18864,7 @@ var ts; case 196: transformFlags |= 192 | 524288; break; - case 259: + case 260: transformFlags |= 8 | 1048576; break; case 96: @@ -18827,22 +18912,22 @@ var ts; transformFlags |= 192; } break; - case 209: case 210: case 211: case 212: + case 213: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 262: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 216: - case 214: + case 217: case 215: + case 216: transformFlags |= 33554432; break; } @@ -18858,18 +18943,18 @@ var ts; case 180: case 175: return 537396545; - case 230: + case 231: return 574674241; case 144: return 536872257; case 185: return 601249089; case 184: - case 225: - return 601281857; - case 224: - return 546309441; case 226: + return 601281857; + case 225: + return 546309441; + case 227: case 197: return 539358529; case 150: @@ -18891,12 +18976,12 @@ var ts; case 153: case 154: case 155: - case 227: case 228: + case 229: return -3; case 176: return 540087617; - case 256: + case 257: return 537920833; case 172: case 173: @@ -18917,6 +19002,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -18924,9 +19015,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -18938,13 +19026,13 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2: - case 0: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -19006,6 +19094,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -19060,7 +19149,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -19076,7 +19169,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -19117,31 +19211,115 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_5 = ts.getDirectoryPath(current); + if (parent_5 === current || directoryPathMap.contains(parent_5)) { + break; + } + directoryPathMap.set(parent_5, result); + current = parent_5; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -19266,33 +19444,33 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -19309,10 +19487,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -19340,11 +19541,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -19353,19 +19554,21 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -19374,16 +19577,22 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -19393,73 +19602,117 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -19471,10 +19724,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -19548,9 +19804,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -19559,6 +19817,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -19581,7 +19840,8 @@ var ts; tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -19675,6 +19935,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var typeofEQFacts = ts.createMap({ @@ -19820,7 +20081,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -19915,7 +20176,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -19959,25 +20220,35 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174) { + var errorBindingElement = ts.getAncestor(usage, 174); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + } + else if (declaration.kind === 224) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: - case 213: + case 206: + case 212: + case 214: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: case 213: + case 214: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -20004,6 +20275,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -20017,7 +20297,7 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 144 || @@ -20040,13 +20320,13 @@ var ts; } } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 231: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { + if (location.kind === 262 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -20056,7 +20336,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + ts.getDeclarationOfKind(moduleExports[name], 244)) { break; } } @@ -20064,7 +20344,7 @@ var ts; break loop; } break; - case 229: + case 230: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } @@ -20080,9 +20360,9 @@ var ts; } } break; - case 226: - case 197: case 227: + case 197: + case 228: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -20100,7 +20380,7 @@ var ts; break; case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; @@ -20112,7 +20392,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; @@ -20176,7 +20456,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 234) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20256,7 +20536,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20273,10 +20553,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 236) { node = node.parent; } return node; @@ -20286,7 +20566,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 246) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20390,19 +20670,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: + case 235: return getTargetOfImportEqualsDeclaration(node); - case 236: - return getTargetOfImportClause(node); case 237: + return getTargetOfImportClause(node); + case 238: return getTargetOfNamespaceImport(node); - case 239: - return getTargetOfImportSpecifier(node); - case 243: - return getTargetOfExportSpecifier(node); case 240: + return getTargetOfImportSpecifier(node); + case 244: + return getTargetOfExportSpecifier(node); + case 241: return getTargetOfExportAssignment(node); - case 233: + case 234: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20446,10 +20726,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 241) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 244) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20465,7 +20745,7 @@ var ts; return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 235); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20762,11 +21042,11 @@ var ts; } } switch (location_1.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230: + case 231: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -20810,7 +21090,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -20842,7 +21122,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -20915,7 +21195,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -20953,7 +21233,7 @@ var ts; meaning = 107455 | 1048576; } else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + entityName.parent.kind === 235) { meaning = 1920; } else { @@ -21048,7 +21328,7 @@ var ts; while (node.kind === 166) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 229) { return getSymbolOfNode(node); } } @@ -21056,7 +21336,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 232 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21125,9 +21405,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21260,12 +21540,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21324,7 +21604,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 262 || declaration.parent.kind === 232; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21337,25 +21617,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); @@ -21438,8 +21699,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -21618,6 +21879,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -21630,7 +21895,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -21648,6 +21912,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 134); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -21658,6 +21948,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -21674,27 +21965,27 @@ var ts; switch (node.kind) { case 174: return isDeclarationVisible(node.parent.parent); - case 223: + case 224: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: + case 231: case 227: case 228: - case 225: case 229: - case 234: + case 226: + case 230: + case 235: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147: case 146: case 151: @@ -21709,7 +22000,7 @@ var ts; case 153: case 155: case 144: - case 231: + case 232: case 158: case 159: case 161: @@ -21720,15 +22011,15 @@ var ts; case 165: case 166: return isDeclarationVisible(node.parent); - case 236: case 237: - case 239: + case 238: + case 240: return false; case 143: - case 261: - case 233: + case 262: + case 234: return true; - case 240: + case 241: return false; default: return false; @@ -21737,10 +22028,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 241) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 244) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -21818,12 +22109,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: case 224: + case 225: + case 240: case 239: case 238: case 237: - case 236: node = node.parent; break; default: @@ -21842,9 +22133,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); @@ -21979,11 +22267,11 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 213) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -21993,7 +22281,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -22031,7 +22319,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (declaration.kind === 259) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -22106,7 +22394,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 258) { return type; } return getWidenedType(type); @@ -22134,10 +22422,10 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 241) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -22344,8 +22632,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || + if (node.kind === 227 || node.kind === 197 || + node.kind === 226 || node.kind === 184 || node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { @@ -22355,15 +22643,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 228 || node.kind === 227 || + node.kind === 197 || node.kind === 229) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22496,7 +22784,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -22525,7 +22813,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 228) { if (declaration.flags & 64) { return false; } @@ -22575,7 +22863,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 286); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -22586,7 +22874,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 229); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -22618,7 +22906,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22646,7 +22934,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -23121,8 +23409,8 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -23393,7 +23681,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 274) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -23404,7 +23692,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 274; } } } @@ -23456,7 +23744,7 @@ var ts; var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -23539,12 +23827,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -23555,7 +23843,7 @@ var ts; case 152: case 184: case 185: - case 274: + case 275: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -23827,7 +24115,7 @@ var ts; switch (node.kind) { case 157: return node.typeName; - case 272: + case 273: return node.name; case 199: var expr = node.expression; @@ -23853,7 +24141,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 273) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -23863,7 +24151,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 273) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -23898,9 +24186,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226: case 227: - case 229: + case 228: + case 230: return declaration; } } @@ -24074,8 +24362,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -24185,8 +24474,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -24304,7 +24593,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -24416,7 +24705,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -24539,7 +24828,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { if (!(ts.getModifierFlags(container) & 32) && (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -24558,8 +24847,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: case 264: + case 265: return anyType; case 134: return stringType; @@ -24577,21 +24866,21 @@ var ts; return nullType; case 129: return neverType; - case 289: - return nullType; case 290: - return undefinedType; + return nullType; case 291: + return undefinedType; + case 292: return neverType; case 167: case 98: return getTypeFromThisTypeNode(node); case 171: return getTypeFromLiteralTypeNode(node); - case 288: + case 289: return getTypeFromLiteralTypeNode(node.literal); case 157: - case 272: + case 273: return getTypeFromTypeReference(node); case 156: return booleanType; @@ -24600,29 +24889,29 @@ var ts; case 160: return getTypeFromTypeQueryNode(node); case 162: - case 265: + case 266: return getTypeFromArrayTypeNode(node); case 163: return getTypeFromTupleTypeNode(node); case 164: - case 266: + case 267: return getTypeFromUnionTypeNode(node); case 165: return getTypeFromIntersectionTypeNode(node); case 166: - case 268: case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); case 270: + case 277: + case 278: + case 274: + return getTypeFromTypeNode(node.type); + case 271: return getTypeFromTypeNode(node.literal); case 158: case 159: case 161: - case 287: - case 274: + case 288: + case 275: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168: return getTypeFromTypeOperatorNode(node); @@ -24634,9 +24923,9 @@ var ts; case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 268: return getTypeFromJSDocTupleType(node); - case 275: + case 276: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24785,17 +25074,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -24816,12 +25107,12 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -24832,10 +25123,10 @@ var ts; case 152: case 184: case 185: - case 226: - case 197: case 227: + case 197: case 228: + case 229: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24845,15 +25136,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 228) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 275: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231: + case 262: return false; } node = node.parent; @@ -24863,7 +25163,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 262 || parentKind === 232; } return false; } @@ -24930,7 +25230,7 @@ var ts; case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 258: return isContextSensitive(node.initializer); case 149: case 148: @@ -24986,7 +25286,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -25688,8 +25988,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -25840,7 +26143,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -26049,8 +26352,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -26058,8 +26361,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -26150,8 +26453,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -26310,7 +26613,7 @@ var ts; case 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 226: case 149: case 148: case 151: @@ -26651,8 +26954,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -26768,7 +27071,7 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 224 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; @@ -26866,8 +27169,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -26953,7 +27256,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + return node.parent.kind === 175 || node.parent.kind === 258 ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -26972,9 +27275,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: - return stringType; case 213: + return stringType; + case 214: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192: return getAssignedTypeOfBinaryExpression(parent); @@ -26984,9 +27287,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196: return getAssignedTypeOfSpreadExpression(parent); - case 257: - return getAssignedTypeOfPropertyAssignment(parent); case 258: + return getAssignedTypeOfPropertyAssignment(parent); + case 259: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -27009,26 +27312,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 213) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 224 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 224 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 224 && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); @@ -27055,7 +27358,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 254) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -27157,8 +27460,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -27700,8 +28003,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || + node.kind === 232 || + node.kind === 262 || node.kind === 147) { return node; } @@ -27771,7 +28074,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 227 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27799,6 +28102,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -27826,7 +28130,7 @@ var ts; flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -27857,7 +28161,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 257) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -27875,8 +28179,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 212 && + ts.getAncestor(symbol.valueDeclaration, 225).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27966,10 +28270,10 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 150: @@ -28027,9 +28331,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 275) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -28323,8 +28627,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -28394,13 +28698,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { + if (attribute.kind === 251) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251) { + else if (attribute.kind === 252) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -28418,14 +28722,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: + case 224: case 144: case 147: case 146: case 174: return getContextualTypeForInitializerExpression(node); case 185: - case 216: + case 217: return getContextualTypeForReturnExpression(node); case 195: return getContextualTypeForYieldOperand(parent); @@ -28437,22 +28741,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192: return getContextualTypeForBinaryOperand(node); - case 257: case 258: + case 259: return getContextualTypeForObjectLiteralElement(parent); case 175: return getContextualTypeForElementExpression(node); case 193: return getContextualTypeForConditionalOperand(node); - case 202: + case 203: ts.Debug.assert(parent.parent.kind === 194); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183: return getContextualType(parent); - case 252: + case 253: return getContextualType(parent); - case 250: case 251: + case 252: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -28504,8 +28808,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -28648,25 +28952,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 258 || + memberDecl.kind === 259 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 258) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 259); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -28692,7 +28996,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { + else if (memberDecl.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(memberDecl, 2); } @@ -28792,13 +29096,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 253: checkJsxExpression(child); break; - case 246: + case 247: checkJsxElement(child); break; - case 247: + case 248: checkJsxSelfClosingElement(child); break; } @@ -29093,11 +29397,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { + if (node.attributes[i].kind === 251) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251); + ts.Debug.assert(node.attributes[i].kind === 252); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -29116,7 +29420,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -29134,7 +29442,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 177 || node.kind === 224 ? node.name : node.right; if (left.kind === 96) { @@ -29280,7 +29588,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 225) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -29302,7 +29610,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 213 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -29398,19 +29706,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -29630,7 +29938,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145) { switch (node.parent.kind) { - case 226: + case 227: case 197: return 1; case 147: @@ -29651,7 +29959,7 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -29672,7 +29980,7 @@ var ts; return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -29709,7 +30017,7 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -30070,7 +30378,7 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: + case 227: case 197: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144: @@ -30180,9 +30488,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 226 : resolvedRequire.flags & 3 - ? 223 + ? 224 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -30208,6 +30516,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -30315,7 +30640,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 205) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -30394,7 +30719,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -30440,7 +30765,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -30506,6 +30831,7 @@ var ts; if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -30520,7 +30846,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 205) { checkSourceElement(node.body); } else { @@ -30573,7 +30899,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 238; } } } @@ -30589,6 +30915,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 && expr.kind !== 178) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -30659,8 +30995,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -30674,8 +31010,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -30684,8 +31020,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -30732,7 +31068,7 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { + if (property.kind === 258 || property.kind === 259) { var name_20 = property.name; if (name_20.kind === 142) { checkComputedPropertyName(name_20); @@ -30747,7 +31083,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 259) { return checkDestructuringAssignment(property, type); } else { @@ -30758,7 +31094,7 @@ var ts; error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); } } - else if (property.kind === 259) { + else if (property.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -30826,7 +31162,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 259) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -30854,7 +31190,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 260 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -30883,8 +31219,8 @@ var ts; case 176: case 187: case 201: + case 248: case 247: - case 246: return true; case 193: return isSideEffectFree(node.whenTrue) && @@ -31318,6 +31654,8 @@ var ts; return checkAssertion(node); case 201: return checkNonNullAssertion(node); + case 202: + return checkMetaProperty(node); case 186: return checkDeleteExpression(node); case 188: @@ -31338,13 +31676,13 @@ var ts; return undefinedWideningType; case 195: return checkYieldExpression(node); - case 252: + case 253: return checkJsxExpression(node); - case 246: - return checkJsxElement(node); case 247: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 248: + return checkJsxSelfClosingElement(node); + case 249: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -31389,7 +31727,7 @@ var ts; return false; } return node.kind === 149 || - node.kind === 225 || + node.kind === 226 || node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -31448,14 +31786,14 @@ var ts; switch (node.parent.kind) { case 185: case 153: - case 225: + case 226: case 184: case 158: case 149: case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -31483,7 +31821,7 @@ var ts; if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || + else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || node.kind === 153 || node.kind === 150 || node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); @@ -31605,7 +31943,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 228) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -31687,7 +32025,7 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 184 && n.kind !== 226) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -31712,7 +32050,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31861,8 +32199,8 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && + if (n.parent.kind !== 228 && + n.parent.kind !== 227 && n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { @@ -31973,11 +32311,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -32088,16 +32426,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 228: return 2097152; - case 230: + case 231: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 227: + case 230: return 2097152 | 1048576; - case 234: + case 235: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -32109,7 +32447,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -32244,7 +32583,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 227: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -32299,7 +32638,7 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 227: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -32332,6 +32671,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -32382,28 +32722,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 262: + case 231: checkUnusedModuleMembers(node); break; - case 226: + case 227: case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 228: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: checkUnusedLocalsAndParameters(node); break; case 150: case 184: - case 225: + case 226: case 185: case 149: case 151: @@ -32427,7 +32767,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -32460,9 +32800,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 224 && + (declaration.parent.parent.kind === 213 || + declaration.parent.parent.kind === 214)) { return; } } @@ -32523,7 +32863,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -32531,7 +32871,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 205) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -32575,6 +32915,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -32591,6 +32936,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -32600,8 +32961,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -32616,11 +32977,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -32628,11 +32989,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -32640,7 +33001,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 224 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -32650,15 +33011,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); + var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || + (container.kind === 205 && ts.isFunctionLike(container.parent) || + container.kind === 232 || container.kind === 231 || - container.kind === 230 || - container.kind === 261); + container.kind === 262); if (!namesShareScope) { var name_23 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); @@ -32691,7 +33052,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 144 || + symbol.valueDeclaration.kind === 174) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -32729,19 +33091,19 @@ var ts; } } if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_24 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -32752,7 +33114,7 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -32761,7 +33123,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32781,18 +33143,19 @@ var ts; } if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 224 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 144 && right.kind === 224) || + (left.kind === 224 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32838,7 +33201,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 207) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32855,12 +33218,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 225) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32878,7 +33241,7 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { checkForInOrForOfVariableDeclaration(node); } else { @@ -32903,7 +33266,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -33160,7 +33523,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 255 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -33172,7 +33535,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 254) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -33198,7 +33561,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 220 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -33321,7 +33684,7 @@ var ts; } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -33341,7 +33704,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { + if (declaration.kind === 227 || declaration.kind === 228) { if (!firstDecl) { firstDecl = declaration; } @@ -33374,6 +33737,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33409,7 +33773,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 227) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -33536,7 +33900,7 @@ var ts; if (!list1 || !list2 || list1.length !== list2.length) { return false; } - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -33594,7 +33958,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -33725,6 +34089,7 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; case 183: return evalConstant(e.expression); @@ -33798,6 +34163,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -33818,7 +34184,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 230) { return false; } var enumDeclaration = declaration; @@ -33841,8 +34207,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 || + (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33901,7 +34267,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 227); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33944,22 +34310,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 206: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: case 241: + case 242: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: case 235: + case 236: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174: - case 223: + case 224: var name_25 = node.name; if (ts.isBindingPattern(name_25)) { for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { @@ -33968,12 +34334,12 @@ var ts; } break; } - case 226: - case 229: - case 225: case 227: case 230: + case 226: case 228: + case 231: + case 229: if (isGlobalAugmentation) { return; } @@ -34009,9 +34375,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -34032,7 +34398,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 244 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -34059,7 +34425,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { checkImportBinding(importClause.namedBindings); } else { @@ -34110,8 +34476,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -34124,7 +34490,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -34147,9 +34513,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 ? node.parent : node.parent.parent; + if (container.kind === 231 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -34215,7 +34586,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 226 && declaration.kind !== 149) || !!declaration.body; } } @@ -34226,10 +34597,10 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -34278,71 +34649,71 @@ var ts; return checkIndexedAccessType(node); case 170: return checkMappedType(node); - case 225: + case 226: return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); case 205: + case 232: + return checkBlock(node); + case 206: return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); case 208: - return checkIfStatement(node); + return checkExpressionStatement(node); case 209: - return checkDoStatement(node); + return checkIfStatement(node); case 210: - return checkWhileStatement(node); + return checkDoStatement(node); case 211: - return checkForStatement(node); + return checkWhileStatement(node); case 212: - return checkForInStatement(node); + return checkForStatement(node); case 213: - return checkForOfStatement(node); + return checkForInStatement(node); case 214: + return checkForOfStatement(node); case 215: - return checkBreakOrContinueStatement(node); case 216: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 217: - return checkWithStatement(node); + return checkReturnStatement(node); case 218: - return checkSwitchStatement(node); + return checkWithStatement(node); case 219: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 220: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 221: + return checkThrowStatement(node); + case 222: return checkTryStatement(node); - case 223: + case 224: return checkVariableDeclaration(node); case 174: return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 228: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 229: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 230: + return checkEnumDeclaration(node); + case 231: return checkModuleDeclaration(node); - case 235: + case 236: return checkImportDeclaration(node); - case 234: + case 235: return checkImportEqualsDeclaration(node); - case 241: + case 242: return checkExportDeclaration(node); - case 240: + case 241: return checkExportAssignment(node); - case 206: + case 207: checkGrammarStatementInAmbientContext(node); return; - case 222: + case 223: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 245: return checkMissingDeclaration(node); } } @@ -34385,6 +34756,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -34404,6 +34776,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -34448,7 +34824,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 218 && node.parent.statement === node) { return true; } node = node.parent; @@ -34470,14 +34846,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; case 197: @@ -34485,8 +34861,8 @@ var ts; if (className) { copySymbol(location.symbol, meaning); } - case 226: case 227: + case 228: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } @@ -34531,10 +34907,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143: - case 226: case 227: case 228: case 229: + case 230: return true; } } @@ -34543,7 +34919,7 @@ var ts; while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -34570,10 +34946,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 235) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 241) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -34597,11 +34973,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + var importEqualsDeclaration = ts.getAncestor(entityName, 235); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -34648,10 +35024,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 251) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156) { @@ -34660,7 +35036,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 262) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -34713,7 +35089,7 @@ var ts; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 236 || node.parent.kind === 242) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -34735,7 +35111,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 259) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -34786,7 +35162,7 @@ var ts; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + if (expr.parent.kind === 214) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -34794,7 +35170,7 @@ var ts; var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 258) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -34905,7 +35281,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -34943,7 +35319,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34983,16 +35359,16 @@ var ts; return true; } switch (node.kind) { - case 234: - case 236: + case 235: case 237: - case 239: - case 243: + case 238: + case 240: + case 244: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241: + case 242: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 241: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -35002,7 +35378,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -35053,7 +35429,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 261) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -35147,9 +35523,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -35262,15 +35638,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -35289,7 +35665,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 262); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -35466,7 +35842,7 @@ var ts; } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 230 && node.parent.kind === 227) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -35492,7 +35868,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -35515,7 +35891,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144) { @@ -35550,7 +35926,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144) { @@ -35565,13 +35941,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -35581,14 +35957,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { + if (node.kind !== 227) { if (node.kind !== 149 && node.kind !== 147 && node.kind !== 151 && node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -35630,7 +36006,7 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 236 || node.kind === 235) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { @@ -35660,29 +36036,29 @@ var ts; case 149: case 148: case 155: - case 230: + case 231: + case 236: case 235: - case 234: + case 242: case 241: - case 240: case 184: case 185: case 144: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 232 || node.parent.kind === 262) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); case 226: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 116); case 228: - return true; + case 206: case 229: + return true; + case 230: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -35696,7 +36072,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149: - case 225: + case 226: case 184: case 185: if (!node.asteriskToken) { @@ -35902,7 +36278,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || + ts.Debug.assert(node.kind === 226 || node.kind === 184 || node.kind === 149); if (ts.isInAmbientContext(node)) { @@ -35929,14 +36305,14 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 260) { continue; } var name_28 = prop.name; if (name_28.kind === 142) { checkGrammarComputedPropertyName(name_28); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { @@ -35948,7 +36324,7 @@ var ts; } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 258 || prop.kind === 259) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_28.kind === 8) { checkGrammarNumericLiteral(name_28); @@ -35997,7 +36373,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 252) { continue; } var jsxAttr = attr; @@ -36009,7 +36385,7 @@ var ts; return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 253 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -36018,7 +36394,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 225) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -36026,20 +36402,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -36123,7 +36499,7 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } else if (node.parent.kind === 161) { @@ -36137,9 +36513,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 220: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 215 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -36147,8 +36523,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 219: + if (node.kind === 216 && !node.label) { return false; } break; @@ -36161,13 +36537,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 216 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 215 + var message = node.kind === 216 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -36193,7 +36569,7 @@ var ts; expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -36250,15 +36626,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: case 209: case 210: - case 217: case 211: + case 218: case 212: case 213: + case 214: return false; - case 219: + case 220: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -36273,6 +36649,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -36313,7 +36696,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36334,13 +36717,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 228 || + node.kind === 229 || + node.kind === 236 || node.kind === 235 || - node.kind === 234 || + node.kind === 242 || node.kind === 241 || - node.kind === 240 || - node.kind === 233 || + node.kind === 234 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -36349,7 +36732,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 205) { + if (ts.isDeclaration(decl) || decl.kind === 206) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -36368,7 +36751,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 205 || node.parent.kind === 232 || node.parent.kind === 262) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -36379,8 +36762,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -36425,31 +36822,31 @@ var ts; _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230] = [ + _a[231] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231] = [ + _a[232] = [ { name: "statements", test: ts.isStatement } ], - _a[234] = [ + _a[235] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245] = [ + _a[246] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260] = [ + _a[261] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -36475,11 +36872,11 @@ var ts; } var result = initial; switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: - case 293: + case 223: + case 294: break; case 142: result = reduceNode(node.expression, cbNode, result); @@ -36620,72 +37017,72 @@ var ts; result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 202: + case 203: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 205: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 206: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 208: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 211: + case 218: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 212: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: case 213: + case 214: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 217: + case 221: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 219: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 222: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 224: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 225: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 226: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -36694,7 +37091,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -36702,92 +37099,92 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232: + case 233: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 237: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 239: case 243: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 240: + case 244: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240: + case 241: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: case 248: + case 249: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249: + case 250: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 251: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; case 252: result = reduceNode(node.expression, cbNode, result); break; case 253: result = reduceNode(node.expression, cbNode, result); + break; case 254: + result = reduceNode(node.expression, cbNode, result); + case 255: result = reduceNodes(node.statements, cbNodes, result); break; - case 255: + case 256: result = reduceNodes(node.types, cbNodes, result); break; - case 256: + case 257: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 258: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 259: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 260: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 262: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 295: result = reduceNode(node.expression, cbNode, result); break; default: @@ -36928,10 +37325,10 @@ var ts; return node; } switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: + case 223: return node; case 142: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); @@ -36999,101 +37396,101 @@ var ts; return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); case 199: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 202: + case 203: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 204: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 205: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 206: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 221: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 222: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 226: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 227: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232: + case 233: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 243: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 244: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 259: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 260: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 261: + case 262: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 295: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -37181,7 +37578,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -37585,15 +37982,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: + case 262: + case 233: case 232: - case 231: - case 204: + case 205: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 227: case 226: - case 225: if (ts.hasModifier(node, 2)) { break; } @@ -37618,13 +38015,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 240: - return visitExportAssignment(node); case 241: + return visitExportAssignment(node); + case 242: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -37634,11 +38031,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || + if (node.kind === 242 || node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + node.kind === 237 || + (node.kind === 235 && + node.moduleReference.kind === 246)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -37662,7 +38059,7 @@ var ts; case 152: case 149: return visitorWorker(node); - case 203: + case 204: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -37719,18 +38116,18 @@ var ts; case 171: case 155: case 145: - case 228: + case 229: case 147: return undefined; case 150: return visitConstructor(node); - case 227: + case 228: return ts.createNotEmittedStatement(node); - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); - case 255: + case 256: return visitHeritageClause(node); case 199: return visitExpressionWithTypeArguments(node); @@ -37740,7 +38137,7 @@ var ts; return visitGetAccessor(node); case 152: return visitSetAccessor(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -37759,15 +38156,15 @@ var ts; return visitNewExpression(node); case 201: return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); case 230: + return visitEnumDeclaration(node); + case 206: + return visitVariableStatement(node); + case 224: + return visitVariableDeclaration(node); + case 231: return visitModuleDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -37921,7 +38318,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -38206,7 +38603,7 @@ var ts; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: + case 227: case 197: return ts.getFirstConstructorWithBody(node) !== undefined; case 149: @@ -38224,7 +38621,7 @@ var ts; return serializeTypeNode(node.type); case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: + case 227: case 197: case 149: return ts.createIdentifier("Function"); @@ -38281,6 +38678,9 @@ var ts; } switch (node.kind) { case 104: + case 137: + case 94: + case 129: return ts.createVoidZero(); case 166: return serializeTypeNode(node.type); @@ -38319,29 +38719,7 @@ var ts; return serializeTypeReferenceNode(node); case 165: case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } + return serializeUnionOrIntersectionType(node); case 160: case 168: case 169: @@ -38356,6 +38734,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -38682,7 +39086,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 230) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -38742,8 +39146,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -38765,13 +39169,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + if (body.kind !== 232) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 231) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -38791,7 +39195,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 238) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -38926,15 +39330,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(259); + context.enableEmitNotification(231); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 230; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -39007,9 +39411,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 262) { + var substitute = (applicableSubstitutions & 2 && container.kind === 231) || + (applicableSubstitutions & 8 && container.kind === 230); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -39124,11 +39528,11 @@ var ts; return visitObjectLiteralExpression(node); case 192: return visitBinaryExpression(node, noDestructuringValue); - case 223: + case 224: return visitVariableDeclaration(node); - case 213: + case 214: return visitForOfStatement(node); - case 211: + case 212: return visitForStatement(node); case 188: return visitVoidExpression(node); @@ -39140,7 +39544,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152: return visitSetAccessorDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -39148,7 +39552,7 @@ var ts; return visitArrowFunction(node); case 144: return visitParameter(node); - case 207: + case 208: return visitExpressionStatement(node); case 183: return visitParenthesizedExpression(node, noDestructuringValue); @@ -39161,7 +39565,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259) { + if (e.kind === 260) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -39173,7 +39577,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 258) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -39346,11 +39750,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: - return visitJsxElement(node, false); case 247: + return visitJsxElement(node, false); + case 248: return visitJsxSelfClosingElement(node, false); - case 252: + case 253: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -39360,11 +39764,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 253: return visitJsxExpression(node); - case 246: - return visitJsxElement(node, true); case 247: + return visitJsxElement(node, true); + case 248: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -39418,7 +39822,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 252) { + else if (node.kind === 253) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -39483,7 +39890,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 247) { return getTagName(node.openingElement); } else { @@ -39802,7 +40209,7 @@ var ts; return visitAwaitExpression(node); case 149: return visitMethodDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -39901,7 +40308,7 @@ var ts; context.enableSubstitution(179); context.enableSubstitution(177); context.enableSubstitution(178); - context.enableEmitNotification(226); + context.enableEmitNotification(227); context.enableEmitNotification(149); context.enableEmitNotification(151); context.enableEmitNotification(152); @@ -39957,7 +40364,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 + return kind === 227 || kind === 150 || kind === 149 || kind === 151 @@ -40096,15 +40503,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -40114,178 +40513,104 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 217 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); case 144: return visitParameter(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 185: return visitArrowFunction(node); case 184: return visitFunctionExpression(node); - case 223: + case 224: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 225: return visitVariableDeclarationList(node); case 219: + return visitSwitchStatement(node); + case 233: + return visitCaseBlock(node); + case 205: + return visitBlock(node, false); + case 216: + case 215: + return visitBreakOrContinueStatement(node); + case 220: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); + return visitDoOrWhileStatement(node, undefined); case 212: - return visitForInStatement(node); + return visitForStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForInStatement(node, undefined); + case 214: + return visitForOfStatement(node, undefined); + case 208: return visitExpressionStatement(node); case 176: return visitObjectLiteralExpression(node); - case 256: + case 257: return visitCatchClause(node); - case 258: + case 259: return visitShorthandPropertyAssignment(node); + case 142: + return visitComputedPropertyName(node); case 175: return visitArrayLiteralExpression(node); case 179: @@ -40310,51 +40635,80 @@ var ts; case 196: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 202: + return visitMetaProperty(node); case 149: return visitMethodDeclaration(node); - case 205: + case 151: + case 152: + return visitAccessorDeclaration(node); + case 206: return visitVariableStatement(node); + case 217: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0, 0); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -40370,13 +40724,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; + var jump = node.kind === 216 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 216) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -40386,7 +40740,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 216) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -40485,6 +40839,9 @@ var ts; } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); @@ -40492,6 +40849,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -40512,23 +40871,26 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { ts.setEmitFlags(block, 1536); @@ -40536,17 +40898,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 217) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 209) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 205) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -40554,8 +40916,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -40575,9 +40937,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression @@ -40592,17 +40953,17 @@ var ts; statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -40698,21 +41059,53 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 185: + return statements; + case 149: + case 151: + case 152: + newTarget = ts.createVoidZero(); + break; + case 150: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 226: + case 184: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 204: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151: case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150: @@ -40726,26 +41119,29 @@ var ts; function transformSemicolonClassElementToStatement(member) { return ts.createEmptyStatement(member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); ts.setEmitFlags(statement, 1536); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -40754,7 +41150,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -40762,7 +41158,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -40778,35 +41174,69 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -40853,6 +41283,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } @@ -40866,6 +41297,21 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { case 183: @@ -40890,9 +41336,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -40909,49 +41358,54 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -40967,48 +41421,51 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; @@ -41071,31 +41528,53 @@ var ts; ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); ts.setEmitFlags(forStatement, 256); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210: + case 211: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212: + return visitForStatement(node, outermostLabeledStatement); + case 213: + return visitForInStatement(node, outermostLabeledStatement); + case 214: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -41119,14 +41598,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -41135,11 +41616,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: case 212: case 213: + case 214: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 225) { loopInitializer = initializer; } break; @@ -41166,7 +41647,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -41178,11 +41659,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, undefined, true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], undefined, true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -41241,19 +41724,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -41367,17 +41849,17 @@ var ts; case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: - expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + case 149: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; case 258: - expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + case 259: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -41399,21 +41881,31 @@ var ts; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -41421,21 +41913,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; + } function visitShorthandPropertyAssignment(node) { return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; + } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -41447,25 +41961,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -41563,21 +42079,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -41595,7 +42124,7 @@ var ts; context.enableEmitNotification(152); context.enableEmitNotification(185); context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } function onSubstituteNode(emitContext, node) { @@ -41621,9 +42150,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174: - case 226: - case 229: - case 223: + case 227: + case 230: + case 224: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -41649,8 +42178,7 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { + && hierarchyFacts & 16) { return ts.createIdentifier("_this", node); } return node; @@ -41667,7 +42195,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { return false; } var statementExpression = statement.expression; @@ -41698,7 +42226,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; @@ -41775,13 +42303,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 218: - return visitSwitchStatement(node); case 219: + return visitSwitchStatement(node); + case 220: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -41789,24 +42317,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); case 151: case 152: return visitAccessorDeclaration(node); - case 205: + case 206: return visitVariableStatement(node); - case 211: - return visitForStatement(node); case 212: + return visitForStatement(node); + case 213: return visitForInStatement(node); - case 215: - return visitBreakStatement(node); - case 214: - return visitContinueStatement(node); case 216: + return visitBreakStatement(node); + case 215: + return visitContinueStatement(node); + case 217: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -41844,7 +42372,7 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -42031,10 +42559,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -42096,7 +42624,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -42156,10 +42684,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -42202,35 +42730,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 205: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 212: + return transformAndEmitForStatement(node); + case 213: return transformAndEmitForInStatement(node); - case 214: - return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 221: + return transformAndEmitThrowStatement(node); + case 222: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -42250,7 +42778,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_37 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_37, variable.name); + hoistVariableDeclaration(name_37); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -42280,7 +42810,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -42514,7 +43044,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 255 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -42524,7 +43054,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 254) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -42645,12 +43175,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_38) { + var clone_7 = ts.getMutableClone(name_38); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -43260,41 +43790,41 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)]), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)]), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ]), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -43319,15 +43849,40 @@ var ts; var ts; (function (ts) { function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249); + context.enableEmitNotification(250); + context.enableEmitNotification(248); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177); - context.enableSubstitution(257); + context.enableSubstitution(258); return transformSourceFile; function transformSourceFile(node) { return node; } + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249: + case 250: + case 248: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -43369,7 +43924,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.enableEmitNotification(262); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -43394,9 +43949,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234: + case 235: return undefined; - case 240: + case 241: return visitExportAssignment(node); } return node; @@ -43448,7 +44003,7 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableEmitNotification(261); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var exportFunctionsMap = ts.createMap(); @@ -43548,7 +44103,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 242 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -43571,7 +44126,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 242) { continue; } var exportDecl = externalImport; @@ -43623,15 +44178,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 236: if (!entry.importClause) { break; } - case 234: + case 235: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 242: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -43653,13 +44208,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return undefined; - case 240: + case 241: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -43780,7 +44335,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 262 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -43802,7 +44357,7 @@ var ts; : preventSubstitution(ts.createAssignment(name, value, location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -43835,10 +44390,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -43937,43 +44492,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitForStatement(node); case 213: + return visitForInStatement(node); + case 214: return visitForOfStatement(node); - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 219: + case 220: return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); case 218: + return visitWithStatement(node); + case 219: return visitSwitchStatement(node); - case 232: + case 233: return visitCaseBlock(node); - case 253: - return visitCaseClause(node); case 254: + return visitCaseClause(node); + case 255: return visitDefaultClause(node); - case 221: + case 222: return visitTryStatement(node); - case 256: + case 257: return visitCatchClause(node); - case 204: + case 205: return visitBlock(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -44101,7 +44656,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 262; } else { return false; @@ -44116,7 +44671,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -44228,7 +44783,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -44271,8 +44826,8 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); + context.enableSubstitution(259); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var currentSourceFile; @@ -44310,14 +44865,7 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; return ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ @@ -44331,6 +44879,36 @@ var ts; ]))) ], node.statements)); } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], undefined, true)); + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ], node.statements)); + } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; var unaliasedModuleNames = []; @@ -44390,23 +44968,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return visitExportDeclaration(node); - case 240: + case 241: return visitExportAssignment(node); - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return node; @@ -44604,7 +45182,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -44636,10 +45214,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -44747,7 +45325,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -44807,7 +45385,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -44816,8 +45394,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), node); + var name_39 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), node); } } } @@ -44881,7 +45459,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -45245,7 +45822,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -45258,7 +45835,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -45402,7 +45979,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 294; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -45416,7 +45993,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 225) { declarationListContainerEnd = end; } } @@ -45691,7 +46268,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 236); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -45763,10 +46340,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 224) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -45777,7 +46354,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 236) { moduleElementEmitInfo.isVisible = true; } else { @@ -45785,12 +46362,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -45961,7 +46538,7 @@ var ts; } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -46078,9 +46655,9 @@ var ts; var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } @@ -46124,10 +46701,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 235 || + (node.parent.kind === 262 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -46136,7 +46713,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 236) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -46154,30 +46731,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); - case 227: - return writeInterfaceDeclaration(node); case 226: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 206: + return writeVariableStatement(node); case 228: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 227: + return writeClassDeclaration(node); case 229: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 230: + return writeEnumDeclaration(node); + case 231: return writeModuleDeclaration(node); - case 234: - return writeImportEqualsDeclaration(node); case 235: + return writeImportEqualsDeclaration(node); + case 236: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 262) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -46185,7 +46762,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 228 && !noDeclare) { write("declare "); } } @@ -46235,7 +46812,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -46258,7 +46835,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 238) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -46275,13 +46852,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 235) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 231) { moduleSpecifier = parent.name; } else { @@ -46349,7 +46926,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 232) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -46447,10 +47024,10 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154: @@ -46464,17 +47041,17 @@ var ts; if (ts.hasModifier(node.parent, 32)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 227) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 225: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -46511,7 +47088,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 227) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -46594,7 +47171,7 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -46617,7 +47194,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 224) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -46632,7 +47209,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -46792,13 +47369,13 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 226) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 226) { write("function "); writeTextOfNode(currentText, node.name); } @@ -46892,7 +47469,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -46905,7 +47482,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 226: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -46982,7 +47559,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -46994,7 +47571,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 225: + case 226: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47046,19 +47623,19 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: - case 227: case 226: - case 228: - case 229: - return emitModuleElement(node, isModuleElementVisible(node)); - case 205: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: case 235: + case 228: + case 227: + case 229: + case 230: + return emitModuleElement(node, isModuleElementVisible(node)); + case 206: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 236: return emitModuleElement(node, !node.importClause); - case 241: + case 242: return emitExportDeclaration(node); case 150: case 149: @@ -47074,11 +47651,11 @@ var ts; case 147: case 146: return emitPropertyDeclaration(node); - case 260: - return emitEnumMemberDeclaration(node); - case 240: - return emitExportAssignment(node); case 261: + return emitEnumMemberDeclaration(node); + case 241: + return emitExportAssignment(node); + case 262: return emitSourceFile(node); } } @@ -47286,7 +47863,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 261: + case 262: return emitSourceFile(node); } } @@ -47409,119 +47986,119 @@ var ts; return emitArrayBindingPattern(node); case 174: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); case 203: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 204: - return emitBlock(node); + return emitSemicolonClassElement(); case 205: - return emitVariableStatement(node); + return emitBlock(node); case 206: - return emitEmptyStatement(); + return emitVariableStatement(node); case 207: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 208: - return emitIfStatement(node); + return emitExpressionStatement(node); case 209: - return emitDoStatement(node); + return emitIfStatement(node); case 210: - return emitWhileStatement(node); + return emitDoStatement(node); case 211: - return emitForStatement(node); + return emitWhileStatement(node); case 212: - return emitForInStatement(node); + return emitForStatement(node); case 213: - return emitForOfStatement(node); + return emitForInStatement(node); case 214: - return emitContinueStatement(node); + return emitForOfStatement(node); case 215: - return emitBreakStatement(node); + return emitContinueStatement(node); case 216: - return emitReturnStatement(node); + return emitBreakStatement(node); case 217: - return emitWithStatement(node); + return emitReturnStatement(node); case 218: - return emitSwitchStatement(node); + return emitWithStatement(node); case 219: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 220: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 221: - return emitTryStatement(node); + return emitThrowStatement(node); case 222: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 223: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 226: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 227: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 231: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 232: + return emitModuleBlock(node); + case 233: return emitCaseBlock(node); - case 234: - return emitImportEqualsDeclaration(node); case 235: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 236: - return emitImportClause(node); + return emitImportDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportClause(node); case 238: - return emitNamedImports(node); + return emitNamespaceImport(node); case 239: - return emitImportSpecifier(node); + return emitNamedImports(node); case 240: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 241: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 242: - return emitNamedExports(node); + return emitExportDeclaration(node); case 243: - return emitExportSpecifier(node); + return emitNamedExports(node); case 244: - return; + return emitExportSpecifier(node); case 245: + return; + case 246: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); case 249: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 252: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxExpression(node); case 254: - return emitDefaultClause(node); + return emitCaseClause(node); case 255: - return emitHeritageClause(node); + return emitDefaultClause(node); case 256: - return emitCatchClause(node); + return emitHeritageClause(node); case 257: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 259: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 260: + return emitSpreadAssignment(node); + case 261: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -47598,14 +48175,14 @@ var ts; return emitAsExpression(node); case 201: return emitNonNullExpression(node); - case 246: - return emitJsxElement(node); + case 202: + return emitMetaProperty(node); case 247: + return emitJsxElement(node); + case 248: return emitJsxSelfClosingElement(node); - case 294: + case 295: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); } } function emitNumericLiteral(node) { @@ -48050,6 +48627,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -48092,27 +48674,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 209) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -48122,7 +48704,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48134,7 +48716,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48144,7 +48726,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48154,11 +48736,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 225) { emit(node); } else { @@ -48185,7 +48767,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -48209,9 +48791,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -48387,7 +48972,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 231) { write("."); emit(body.name); body = body.body; @@ -48538,6 +49123,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -48737,8 +49325,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -48867,6 +49455,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -49047,21 +49643,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_40 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name_41 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_40; + return name_41; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -49095,22 +49691,32 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 231: case 230: - case 229: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 236: + case 242: return generateNameForImportOrExportDeclaration(node); - case 225: case 226: - case 240: + case 227: + case 241: return generateNameForExportDefault(); case 197: return generateNameForClassExpression(); + case 149: + case 151: + case 152: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } @@ -49141,11 +49747,14 @@ var ts; } return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } function getGeneratedIdentifier(name) { if (name.autoGenerateKind === 4) { var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { var autoGenerateId = name.autoGenerateId; @@ -49214,7 +49823,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -49397,10 +50007,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name_43 = names_1[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -49425,6 +50035,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -49437,7 +50048,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -49473,6 +50085,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -49679,7 +50292,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -49837,42 +50450,42 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: - case 223: + case 226: + case 224: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 235: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 241: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 256: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 228: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182: @@ -49890,23 +50503,23 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: + case 227: case 149: case 148: case 150: case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: + case 226: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 206: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 206); } break; case 147: @@ -50018,7 +50631,7 @@ var ts; && !file.isDeclarationFile) { var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); + var importDecl = ts.createSynthesizedNode(236); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -50036,9 +50649,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 236: case 235: - case 234: - case 241: + case 242: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -50050,7 +50663,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 231: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -51207,9 +51820,9 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { - switch (name_43) { + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { + switch (name_44) { case "init": case "watch": case "version": @@ -51217,12 +51830,12 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_43] = value; + result[name_44] = value; } else { if (optionDefinition.type === "list") { @@ -51231,10 +51844,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name_44] = convertedValue; } else { - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -51268,6 +51881,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -52084,17 +52698,17 @@ var ts; var nameSize = 0; var valueSize = 0; for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) { - var _a = statistics_1[_i], name_44 = _a.name, value = _a.value; - if (name_44.length > nameSize) { - nameSize = name_44.length; + var _a = statistics_1[_i], name_45 = _a.name, value = _a.value; + if (name_45.length > nameSize) { + nameSize = name_45.length; } if (value.length > valueSize) { valueSize = value.length; } } for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) { - var _c = statistics_2[_b], name_45 = _c.name, value = _c.value; - ts.sys.write(padRight(name_45 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); + var _c = statistics_2[_b], name_46 = _c.name, value = _c.value; + ts.sys.write(padRight(name_46 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); } } function reportStatisticalValue(name, value) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 9c17684ed0a..2d477ca2dcf 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 ts; (function (ts) { var OperationCanceledException = (function () { @@ -206,7 +211,7 @@ var ts; ts.toPath = toPath; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +230,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +240,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -245,7 +250,7 @@ var ts; } ts.find = find; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +273,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +283,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -981,6 +986,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2475,7 +2481,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -2632,6 +2638,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2861,6 +2868,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2870,6 +2879,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2921,6 +2931,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -3089,6 +3101,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,10 +3115,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -3154,6 +3167,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3210,22 +3225,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3606,7 +3624,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +3810,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -5539,6 +5557,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -6156,6 +6175,7 @@ var ts; newLineCharacter: host.newLine || "\n", convertTabsToSpaces: true, indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, insertSpaceAfterCommaDelimiter: true, insertSpaceAfterSemicolonInForStatements: true, insertSpaceBeforeAndAfterBinaryOperators: true, @@ -6163,8 +6183,10 @@ var ts; insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, }; @@ -6293,6 +6315,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -6300,9 +6328,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -6314,13 +6339,13 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2: - case 0: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -6382,6 +6407,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -6436,7 +6462,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -6452,7 +6482,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -6493,31 +6524,115 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_1 = ts.getDirectoryPath(current); + if (parent_1 === current || directoryPathMap.contains(parent_1)) { + break; + } + directoryPathMap.set(parent_1, result); + current = parent_1; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -6642,33 +6757,33 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -6685,10 +6800,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6716,11 +6854,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -6729,19 +6867,21 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -6750,16 +6890,22 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -6769,73 +6915,117 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -6847,10 +7037,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -6981,7 +7174,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { + while (node && node.kind !== 262) { node = node.parent; } return node; @@ -6989,11 +7182,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: return true; } return false; @@ -7058,18 +7251,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 292 && node._children.length > 0) { + if (node.kind === 293 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; + return node.kind >= 263 && node.kind <= 289; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; + return node.kind >= 279 && node.kind <= 292; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -7163,11 +7356,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; + return node.kind === 224 && node.parent.kind === 257; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 && + return node && node.kind === 231 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -7176,11 +7369,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); + return node.kind === 231 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || + return node.kind === 262 || + node.kind === 231 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7193,9 +7386,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261: + case 262: return ts.isExternalModule(node.parent); - case 231: + case 232: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7207,22 +7400,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261: - case 232: - case 256: - case 230: - case 211: + case 262: + case 233: + case 257: + case 231: case 212: case 213: + case 214: case 150: case 149: case 151: case 152: - case 225: + case 226: case 184: case 185: return true; - case 204: + case 205: return parentNode && !isFunctionLike(parentNode); } return false; @@ -7300,7 +7493,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { + if (node.body && node.body.kind === 205) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7312,26 +7505,26 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261: + case 262: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 223: + case 224: case 174: - case 226: - case 197: case 227: + case 197: + case 228: + case 231: case 230: - case 229: - case 260: - case 225: + case 261: + case 226: case 184: case 149: case 151: case 152: - case 228: + case 229: errorNode = node.name; break; case 185: @@ -7355,7 +7548,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); + return node.kind === 230 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7372,7 +7565,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 + return node.kind === 208 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -7429,24 +7622,24 @@ var ts; case 141: case 177: case 98: - var parent_1 = node.parent; - if (parent_1.kind === 160) { + var parent_2 = node.parent; + if (parent_2.kind === 160) { return false; } - if (156 <= parent_1.kind && parent_1.kind <= 171) { + if (156 <= parent_2.kind && parent_2.kind <= 171) { return true; } - switch (parent_1.kind) { + switch (parent_2.kind) { case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); case 143: - return node === parent_1.constraint; + return node === parent_2.constraint; case 147: case 146: case 144: - case 223: - return node === parent_1.type; - case 225: + case 224: + return node === parent_2.type; + case 226: case 184: case 185: case 150: @@ -7454,16 +7647,16 @@ var ts; case 148: case 151: case 152: - return node === parent_1.type; + return node === parent_2.type; case 153: case 154: case 155: - return node === parent_1.type; + return node === parent_2.type; case 182: - return node === parent_1.type; + return node === parent_2.type; case 179: case 180: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 181: return false; } @@ -7471,27 +7664,41 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216: + case 217: return visitor(node); - case 232: - case 204: - case 208: + case 233: + case 205: case 209: case 210: case 211: case 212: case 213: - case 217: + case 214: case 218: - case 253: - case 254: case 219: - case 221: - case 256: + case 254: + case 255: + case 220: + case 222: + case 257: return ts.forEachChild(node, traverse); } } @@ -7507,11 +7714,11 @@ var ts; if (operand) { traverse(operand); } - case 229: - case 227: case 230: case 228: - case 226: + case 231: + case 229: + case 227: case 197: return; default: @@ -7545,13 +7752,13 @@ var ts; if (node) { switch (node.kind) { case 174: - case 260: + case 261: case 144: - case 257: + case 258: case 147: case 146: - case 258: - case 223: + case 259: + case 224: return true; } } @@ -7563,7 +7770,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); + return node && (node.kind === 227 || node.kind === 197); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7574,7 +7781,7 @@ var ts; switch (kind) { case 150: case 184: - case 225: + case 226: case 185: case 149: case 148: @@ -7597,7 +7804,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: return true; } @@ -7606,20 +7813,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return true; - case 219: + case 220: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); + return node && node.kind === 205 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -7683,9 +7902,9 @@ var ts; if (!includeArrowFunctions) { continue; } - case 225: + case 226: case 184: - case 230: + case 231: case 147: case 146: case 149: @@ -7696,13 +7915,26 @@ var ts; case 153: case 154: case 155: - case 229: - case 261: + case 230: + case 262: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 150: + case 226: + case 184: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -7713,7 +7945,7 @@ var ts; case 142: node = node.parent; break; - case 225: + case 226: case 184: case 185: if (!stopOnFunctions) { @@ -7742,13 +7974,13 @@ var ts; function getImmediatelyInvokedFunctionExpression(func) { if (func.kind === 184 || func.kind === 185) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent_3 = func.parent; + while (parent_3.kind === 183) { + prev = parent_3; + parent_3 = parent_3.parent; } - if (parent_2.kind === 179 && parent_2.expression === prev) { - return parent_2; + if (parent_3.kind === 179 && parent_3.expression === prev) { + return parent_3; } } } @@ -7762,7 +7994,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157: - case 272: + case 273: return node.typeName; case 199: return isEntityNameExpression(node.expression) @@ -7796,21 +8028,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226: + case 227: return true; case 147: - return node.parent.kind === 226; + return node.parent.kind === 227; case 151: case 152: case 149: return node.body !== undefined - && node.parent.kind === 226; + && node.parent.kind === 227; case 144: return node.parent.body !== undefined && (node.parent.kind === 150 || node.parent.kind === 149 || node.parent.kind === 152) - && node.parent.parent.kind === 226; + && node.parent.parent.kind === 227; } return false; } @@ -7826,7 +8058,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226: + case 227: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149: case 152: @@ -7836,9 +8068,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { + if (parent.kind === 249 || + parent.kind === 248 || + parent.kind === 250) { return parent.tagName === node; } return false; @@ -7877,10 +8109,11 @@ var ts; case 194: case 12: case 198: - case 246: case 247: + case 248: case 195: case 189: + case 202: return true; case 141: while (node.parent.kind === 141) { @@ -7894,53 +8127,53 @@ var ts; case 8: case 9: case 98: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223: + var parent_4 = node.parent; + switch (parent_4.kind) { + case 224: case 144: case 147: case 146: - case 260: - case 257: + case 261: + case 258: case 174: - return parent_3.initializer === node; - case 207: + return parent_4.initializer === node; case 208: case 209: case 210: - case 216: + case 211: case 217: case 218: - case 253: - case 220: - case 218: - return parent_3.expression === node; - case 211: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + case 219: + case 254: + case 221: + case 219: + return parent_4.expression === node; + case 212: + var forStatement = parent_4; + return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || forStatement.condition === node || forStatement.incrementor === node; - case 212: case 213: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + case 214: + var forInStatement = parent_4; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || forInStatement.expression === node; case 182: case 200: - return node === parent_3.expression; - case 202: - return node === parent_3.expression; + return node === parent_4.expression; + case 203: + return node === parent_4.expression; case 142: - return node === parent_3.expression; + return node === parent_4.expression; case 145: + case 253: case 252: - case 251: - case 259: + case 260: return true; case 199: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent_4)) { return true; } } @@ -7955,7 +8188,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; + return node.kind === 235 && node.moduleReference.kind === 246; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7964,7 +8197,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; + return node.kind === 235 && node.moduleReference.kind !== 246; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7988,7 +8221,7 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184; } @@ -8035,35 +8268,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235) { + if (node.kind === 236) { return node.moduleSpecifier; } - if (node.kind === 234) { + if (node.kind === 235) { var reference = node.moduleReference; - if (reference.kind === 245) { + if (reference.kind === 246) { return reference.expression; } } - if (node.kind === 241) { + if (node.kind === 242) { return node.moduleSpecifier; } - if (node.kind === 230 && node.name.kind === 9) { + if (node.kind === 231 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 + return node.kind === 236 && node.importClause && !!node.importClause.name; } @@ -8074,8 +8307,8 @@ var ts; case 144: case 149: case 148: + case 259: case 258: - case 257: case 147: case 146: return node.questionToken !== undefined; @@ -8085,9 +8318,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 && + return node.kind === 275 && node.parameters.length > 0 && - node.parameters[0].type.kind === 276; + node.parameters[0].type.kind === 277; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -8100,7 +8333,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281) { + if (doc.kind === 282) { if (doc.kind === kind) { result.push(doc); } @@ -8126,9 +8359,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205; + parent.parent.parent.kind === 206; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; + parent.parent.kind === 206; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -8138,13 +8371,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 && parent.operatorToken.kind === 57 && - parent.parent.kind === 207; + parent.parent.kind === 208; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; + var isModuleDeclaration = node.kind === 231 && + parent && parent.kind === 231; + var isPropertyAssignmentExpression = parent && parent.kind === 258; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -8162,17 +8395,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281); + var tags = getJSDocTags(func, 282); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { var name_8 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_8; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_8; }); } else { return undefined; @@ -8180,7 +8413,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); + var tag = getFirstJSDocTag(node, 284); if (!tag && node.kind === 144) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -8191,15 +8424,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); + return getFirstJSDocTag(node, 281); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); + return getFirstJSDocTag(node, 283); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -8212,8 +8445,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { + if (node.type && node.type.kind === 276 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { return true; } } @@ -8237,19 +8470,19 @@ var ts; case 191: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: case 213: + case 214: return parent.initializer === node ? 1 : 0; case 183: case 175: case 196: node = parent; break; - case 258: + case 259: if (parent.name !== node) { return 0; } - case 257: + case 258: node = parent.parent; break; default: @@ -8263,6 +8496,17 @@ var ts; return getAssignmentTargetKind(node) !== 0; } ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 177 && node.kind !== 178) { + return false; + } + node = node.parent; + while (node && node.kind === 183) { + node = node.parent; + } + return node && node.kind === 186; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -8274,7 +8518,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8287,7 +8531,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { + if (parent.kind === 240 || parent.kind === 244) { if (parent.propertyName) { return true; } @@ -8313,8 +8557,8 @@ var ts; case 148: case 151: case 152: - case 260: - case 257: + case 261: + case 258: case 177: return parent.name === node; case 141: @@ -8326,22 +8570,22 @@ var ts; } return false; case 174: - case 239: + case 240: return parent.propertyName === node; - case 243: + case 244: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || - node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); + return node.kind === 235 || + node.kind === 234 || + node.kind === 237 && !!node.name || + node.kind === 238 || + node.kind === 240 || + node.kind === 244 || + node.kind === 241 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8521,13 +8765,13 @@ var ts; var kind = node.kind; return kind === 150 || kind === 184 - || kind === 225 + || kind === 226 || kind === 185 || kind === 149 || kind === 151 || kind === 152 - || kind === 230 - || kind === 261; + || kind === 231 + || kind === 262; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8649,14 +8893,13 @@ var ts; case 184: case 185: case 197: - case 246: case 247: + case 248: case 11: case 12: case 194: case 183: case 198: - case 297: return 19; case 181: case 177: @@ -8830,13 +9073,12 @@ var ts; "\u0085": "\\u0085" }); function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -9712,8 +9954,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229: case 230: + case 231: return parseNode === parseNode.parent.name; } } @@ -9731,7 +9973,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { + if (declaration.kind === 227 && declaration !== node) { return true; } } @@ -9782,6 +10024,10 @@ var ts; return node.kind === 70; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { return isIdentifier(node) && node.autoGenerateKind > 0; } @@ -9849,18 +10095,18 @@ var ts; || kind === 151 || kind === 152 || kind === 155 - || kind === 203; + || kind === 204; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 - || kind === 258 + return kind === 258 || kind === 259 + || kind === 260 || kind === 149 || kind === 151 || kind === 152 - || kind === 244; + || kind === 245; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { @@ -9913,7 +10159,7 @@ var ts; ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223: + case 224: case 144: case 174: return true; @@ -9991,8 +10237,8 @@ var ts; || kind === 178 || kind === 180 || kind === 179 - || kind === 246 || kind === 247 + || kind === 248 || kind === 181 || kind === 175 || kind === 183 @@ -10011,7 +10257,7 @@ var ts; || kind === 100 || kind === 96 || kind === 201 - || kind === 297; + || kind === 202; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10039,7 +10285,6 @@ var ts; || kind === 196 || kind === 200 || kind === 198 - || kind === 297 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10053,11 +10298,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294; + return node.kind === 295; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293; + return node.kind === 294; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10070,11 +10315,11 @@ var ts; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 202; + return node.kind === 203; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 204; + return node.kind === 205; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10092,121 +10337,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223; + return node.kind === 224; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224; + return node.kind === 225; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232; + return node.kind === 233; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 - || kind === 230; + return kind === 232 + || kind === 231; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 - || kind === 237; + return kind === 239 + || kind === 238; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239; + return node.kind === 240; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242; + return node.kind === 243; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243; + return node.kind === 244; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 231 || node.kind === 230; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 || kind === 174 - || kind === 226 + || kind === 227 || kind === 197 || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 + || kind === 230 + || kind === 261 + || kind === 244 + || kind === 226 || kind === 184 || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 + || kind === 237 + || kind === 235 + || kind === 240 + || kind === 228 || kind === 149 || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 + || kind === 231 + || kind === 234 + || kind === 238 || kind === 144 - || kind === 257 + || kind === 258 || kind === 147 || kind === 146 || kind === 152 - || kind === 258 - || kind === 228 + || kind === 259 + || kind === 229 || kind === 143 - || kind === 223 - || kind === 285; + || kind === 224 + || kind === 286; } function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 + return kind === 226 + || kind === 245 || kind === 227 || kind === 228 || kind === 229 || kind === 230 + || kind === 231 + || kind === 236 || kind === 235 - || kind === 234 + || kind === 242 || kind === 241 - || kind === 240 - || kind === 233; + || kind === 234; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 - || kind === 216 - || kind === 218 - || kind === 220 - || kind === 221 - || kind === 205 + return kind === 216 + || kind === 215 + || kind === 223 || kind === 210 + || kind === 208 + || kind === 207 + || kind === 213 + || kind === 214 + || kind === 212 + || kind === 209 + || kind === 220 || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; + || kind === 219 + || kind === 221 + || kind === 222 + || kind === 206 + || kind === 211 + || kind === 218 + || kind === 294 + || kind === 297 + || kind === 296; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10224,22 +10469,22 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204; + || kind === 205; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 245 + return kind === 246 || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 248; + return node.kind === 249; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249; + return node.kind === 250; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -10251,60 +10496,60 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 + return kind === 247 + || kind === 253 + || kind === 248 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 - || kind === 251; + return kind === 251 + || kind === 252; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 252; + || kind === 253; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 - || kind === 254; + return kind === 254 + || kind === 255; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255; + return node.kind === 256; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256; + return node.kind === 257; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 257; + return node.kind === 258; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 261; + return node.kind === 262; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10445,7 +10690,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { return current; } } @@ -10465,14 +10710,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= ts.getModifierFlags(node); } return flags; @@ -10481,14 +10726,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= node.flags; } return flags; @@ -10547,7 +10792,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 + var ConstructorForKind = kind === 262 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -11243,7 +11488,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + var node = createNode(203, location); node.expression = expression; node.literal = literal; return node; @@ -11257,7 +11502,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + var block = createNode(205, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11273,7 +11518,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + var node = createNode(206, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11288,7 +11533,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + var node = createNode(225, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11301,7 +11546,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); + var node = createNode(224, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11316,11 +11561,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206, location); + return createNode(207, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); + var node = createNode(208, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11333,7 +11578,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11348,7 +11593,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209, location); + var node = createNode(210, location); node.statement = statement; node.expression = expression; return node; @@ -11362,7 +11607,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210, location); + var node = createNode(211, location); node.expression = expression; node.statement = statement; return node; @@ -11376,7 +11621,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + var node = createNode(212, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11392,7 +11637,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11407,7 +11652,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11422,7 +11667,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -11437,7 +11682,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215, location); + var node = createNode(216, location); if (label) { node.label = label; } @@ -11452,7 +11697,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.expression = expression; return node; } @@ -11465,7 +11710,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217, location); + var node = createNode(218, location); node.expression = expression; node.statement = statement; return node; @@ -11479,7 +11724,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); + var node = createNode(219, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11493,7 +11738,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219, location); + var node = createNode(220, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11507,7 +11752,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220, location); + var node = createNode(221, location); node.expression = expression; return node; } @@ -11520,7 +11765,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11535,7 +11780,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.clauses = createNodeArray(clauses); return node; } @@ -11548,7 +11793,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); + var node = createNode(226, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11568,7 +11813,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); + var node = createNode(227, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11586,7 +11831,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11602,7 +11847,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11616,7 +11861,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.name = name; return node; } @@ -11629,7 +11874,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.elements = createNodeArray(elements); return node; } @@ -11642,7 +11887,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + var node = createNode(240, location); node.propertyName = propertyName; node.name = name; return node; @@ -11656,7 +11901,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11672,7 +11917,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11688,7 +11933,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.elements = createNodeArray(elements); return node; } @@ -11701,7 +11946,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11715,7 +11960,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + var node = createNode(247, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11730,7 +11975,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11744,7 +11989,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + var node = createNode(249, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11758,7 +12003,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + var node = createNode(250, location); node.tagName = tagName; return node; } @@ -11771,7 +12016,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + var node = createNode(251, location); node.name = name; node.initializer = initializer; return node; @@ -11785,7 +12030,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -11797,21 +12042,22 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(255, location); + var node = createNode(256, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11825,7 +12071,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253, location); + var node = createNode(254, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11839,7 +12085,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254, location); + var node = createNode(255, location); node.statements = createNodeArray(statements); return node; } @@ -11852,7 +12098,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + var node = createNode(257, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11866,7 +12112,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); + var node = createNode(258, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11881,14 +12127,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); + var node = createNode(259, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259, location); + var node = createNode(260, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -11909,7 +12155,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createNode(262, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11969,27 +12215,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createNode(294, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createNode(297); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createNode(296); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + var node = createNode(295, location || original); node.expression = expression; node.original = original; return node; @@ -12002,12 +12248,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; function createComma(left, right) { return createBinary(left, 25, right); } @@ -12171,6 +12411,19 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12270,9 +12523,9 @@ var ts; case 151: case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); case 258: + return createExpressionForPropertyAssignment(property, receiver); + case 259: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149: return createExpressionForMethodDeclaration(property, receiver); @@ -12630,7 +12883,7 @@ var ts; case 177: node = node.expression; continue; - case 294: + case 295: node = node.expression; continue; } @@ -12678,7 +12931,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { + while (node.kind === 295) { node = node.expression; } return node; @@ -12738,7 +12991,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 262) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12929,10 +13182,10 @@ var ts; var name_11 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { + if (node.kind === 236 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { + if (node.kind === 242 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12996,11 +13249,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 258: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 259: + return bindingElement.name; + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -13020,7 +13273,7 @@ var ts; case 174: return bindingElement.dotDotDotToken; case 196: - case 259: + case 260: return bindingElement; } return undefined; @@ -13036,7 +13289,7 @@ var ts; : propertyName; } break; - case 257: + case 258: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13044,7 +13297,7 @@ var ts; : propertyName; } break; - case 259: + case 260: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -13149,15 +13402,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 236: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 235: + if (node.moduleReference.kind === 246) { externalImports.push(node); } break; - case 241: + case 242: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13184,12 +13437,12 @@ var ts; } } break; - case 240: + case 241: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 206: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13197,7 +13450,7 @@ var ts; } } break; - case 225: + case 226: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13215,7 +13468,7 @@ var ts; } } break; - case 226: + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13263,7 +13516,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 262) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { @@ -13312,20 +13565,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259: + case 260: return visitNode(cbNode, node.expression); case 144: case 147: case 146: - case 257: - case 223: + case 258: + case 224: case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13351,7 +13604,7 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13443,6 +13696,8 @@ var ts; visitNode(cbNode, node.type); case 201: return visitNode(cbNode, node.expression); + case 202: + return visitNode(cbNode, node.name); case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -13451,84 +13706,77 @@ var ts; visitNode(cbNode, node.whenFalse); case 196: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 205: + case 232: return visitNodes(cbNodes, node.statements); - case 261: + case 262: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 206: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 225: return visitNodes(cbNodes, node.declarations); - case 207: - return visitNode(cbNode, node.expression); case 208: + return visitNode(cbNode, node.expression); + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 210: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 211: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 212: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + case 216: + return visitNode(cbNode, node.label); + case 217: + return visitNode(cbNode, node.expression); case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232: + case 233: return visitNodes(cbNodes, node.clauses); - case 253: + case 254: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254: + case 255: return visitNodes(cbNodes, node.statements); - case 219: + case 220: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220: - return visitNode(cbNode, node.expression); case 221: + return visitNode(cbNode, node.expression); + case 222: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 257: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145: return visitNode(cbNode, node.expression); - case 226: - case 197: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 227: + case 197: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13540,143 +13788,151 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 261: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 237: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: - return visitNode(cbNode, node.name); - case 237: + case 234: return visitNode(cbNode, node.name); case 238: - case 242: + return visitNode(cbNode, node.name); + case 239: + case 243: return visitNodes(cbNodes, node.elements); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 240: + case 244: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 203: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142: return visitNode(cbNode, node.expression); - case 255: + case 256: return visitNodes(cbNodes, node.types); case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: - return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNode(cbNode, node.expression); + case 245: + return visitNodes(cbNodes, node.decorators); + case 247: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: case 248: + case 249: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250: + case 251: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251: - return visitNode(cbNode, node.expression); case 252: return visitNode(cbNode, node.expression); - case 249: + case 253: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250: return visitNode(cbNode, node.tagName); - case 262: + case 263: return visitNode(cbNode, node.type); - case 266: - return visitNodes(cbNodes, node.types); case 267: return visitNodes(cbNodes, node.types); - case 265: + case 268: + return visitNodes(cbNodes, node.types); + case 266: return visitNode(cbNode, node.elementType); + case 270: + return visitNode(cbNode, node.type); case 269: return visitNode(cbNode, node.type); - case 268: - return visitNode(cbNode, node.type); - case 270: + case 271: return visitNode(cbNode, node.literal); - case 272: + case 273: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273: - return visitNode(cbNode, node.type); case 274: + return visitNode(cbNode, node.type); + case 275: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); case 276: return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNode(cbNode, node.type); + case 272: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 279: return visitNodes(cbNodes, node.tags); - case 281: + case 282: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: - return visitNode(cbNode, node.typeExpression); case 283: return visitNode(cbNode, node.typeExpression); - case 280: - return visitNode(cbNode, node.typeExpression); case 284: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 281: + return visitNode(cbNode, node.typeExpression); case 285: + return visitNodes(cbNodes, node.typeParameters); + case 286: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 288: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 287: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 295: return visitNode(cbNode, node.expression); - case 288: + case 289: return visitNode(cbNode, node.literal); } } @@ -13840,7 +14096,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14459,7 +14715,7 @@ var ts; case 151: case 152: case 147: - case 203: + case 204: return true; case 149: var methodDeclaration = node; @@ -14473,8 +14729,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: case 254: + case 255: return true; } } @@ -14483,42 +14739,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: + case 226: + case 206: case 205: - case 204: + case 209: case 208: - case 207: - case 220: + case 221: + case 217: + case 219: case 216: - case 218: case 215: + case 213: case 214: case 212: - case 213: case 211: - case 210: - case 217: - case 206: - case 221: - case 219: - case 209: + case 218: + case 207: case 222: + case 220: + case 210: + case 223: + case 236: case 235: - case 234: + case 242: case 241: - case 240: - case 230: - case 226: + case 231: case 227: - case 229: case 228: + case 230: + case 229: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } function isReusableTypeMember(node) { if (node) { @@ -14534,7 +14790,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 224) { return false; } var variableDeclarator = node; @@ -14666,7 +14922,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(203); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -15791,8 +16047,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 249) { + var node = createNode(247, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15802,7 +16058,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 248); result = opening; } if (inExpressionContext && token() === 26) { @@ -15862,7 +16118,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(249, fullStart); scanJsxText(); } else { @@ -15874,7 +16130,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(248, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15893,9 +16149,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(253); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -15912,7 +16169,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(251); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15927,7 +16184,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(252); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15935,7 +16192,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(250); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16152,7 +16409,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(260, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16171,7 +16428,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(259, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -16182,7 +16439,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(258, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16228,8 +16485,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(202, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -16238,7 +16502,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(205); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16269,12 +16533,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(207); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16284,7 +16548,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -16295,7 +16559,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16318,21 +16582,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(213, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + var forOfStatement = createNode(214, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(212, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -16350,7 +16614,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 216 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16358,7 +16622,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16367,7 +16631,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16376,7 +16640,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(254); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -16384,7 +16648,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(255); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -16394,12 +16658,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(233, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -16407,14 +16671,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(221); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -16425,7 +16689,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(257); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16435,7 +16699,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -16444,13 +16708,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(220, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(208, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16602,9 +16866,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); - case 71: return parseBreakOrContinueStatement(215); + case 71: + return parseBreakOrContinueStatement(216); case 95: return parseReturnStatement(); case 106: @@ -16683,7 +16947,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16755,7 +17019,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(224); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16764,7 +17028,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(225); switch (token()) { case 103: break; @@ -16793,7 +17057,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16801,7 +17065,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16986,7 +17250,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(204); nextToken(); return finishNode(result); } @@ -17020,7 +17284,7 @@ var ts; return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17055,7 +17319,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(256); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -17078,7 +17342,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -17089,7 +17353,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136); @@ -17101,13 +17365,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(261, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -17122,7 +17386,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(232, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -17133,7 +17397,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -17145,7 +17409,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139) { @@ -17190,7 +17454,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(234, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -17206,7 +17470,7 @@ var ts; if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + var importEqualsDeclaration = createNode(235, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17216,7 +17480,7 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(236, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || @@ -17230,13 +17494,13 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(237, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); } return finishNode(importClause); } @@ -17246,7 +17510,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(246); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -17264,7 +17528,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(238); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -17272,14 +17536,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(244); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(240); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17298,13 +17562,13 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 240 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { @@ -17312,7 +17576,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); + node.exportClause = parseNamedImportsOrExports(243); if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); @@ -17322,7 +17586,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(241, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -17401,10 +17665,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 + || node.kind === 235 && node.moduleReference.kind === 246 + || node.kind === 236 || node.kind === 241 + || node.kind === 242 ? node : undefined; }); @@ -17440,7 +17704,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(263, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -17451,12 +17715,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(267, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(274, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17467,20 +17731,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(266, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(269, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(270, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17532,27 +17796,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(278); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(276); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(275); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -17573,7 +17837,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(273); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -17613,18 +17877,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(271); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(270); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(268); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -17638,7 +17902,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(267); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -17654,12 +17918,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(264); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(289); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17672,11 +17936,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(265, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(269, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17820,7 +18084,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(279, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17930,7 +18194,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17985,7 +18249,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17996,20 +18260,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18024,7 +18288,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18033,7 +18297,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -18042,7 +18306,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(286, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -18056,7 +18320,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 273) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { var name_16 = jsDocTypeReference.name; @@ -18074,7 +18338,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18115,7 +18379,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(231, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18159,7 +18423,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); @@ -18182,7 +18446,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18474,7 +18738,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -18501,16 +18765,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 228 || node.kind === 229) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 232) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18526,7 +18790,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 231) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -18635,7 +18899,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { symbol.valueDeclaration = node; } } @@ -18666,9 +18930,9 @@ var ts; return "__new"; case 155: return "__index"; - case 241: + case 242: return "__export"; - case 240: + case 241: return node.isExportEquals ? "export=" : "default"; case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -18682,20 +18946,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: case 226: + case 227: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 275: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144: - ts.Debug.assert(node.parent.kind === 274); + ts.Debug.assert(node.parent.kind === 275); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 286: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -18739,7 +19003,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18759,7 +19023,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18767,7 +19031,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18828,7 +19092,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 262) { node.flags |= emitFlags; } if (isIIFE) { @@ -18904,43 +19168,43 @@ var ts; return; } switch (node.kind) { - case 210: + case 211: bindWhileStatement(node); break; - case 209: + case 210: bindDoStatement(node); break; - case 211: + case 212: bindForStatement(node); break; - case 212: case 213: + case 214: bindForInOrForOfStatement(node); break; - case 208: + case 209: bindIfStatement(node); break; - case 216: - case 220: + case 217: + case 221: bindReturnOrThrow(node); break; + case 216: case 215: - case 214: bindBreakOrContinueStatement(node); break; - case 221: + case 222: bindTryStatement(node); break; - case 218: + case 219: bindSwitchStatement(node); break; - case 232: + case 233: bindCaseBlock(node); break; - case 253: + case 254: bindCaseClause(node); break; - case 219: + case 220: bindLabeledStatement(node); break; case 190: @@ -18958,7 +19222,7 @@ var ts; case 193: bindConditionalExpressionFlow(node); break; - case 223: + case 224: bindVariableDeclarationFlow(node); break; case 179: @@ -19124,11 +19388,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: - case 210: case 209: - return parent.expression === node; case 211: + case 210: + return parent.expression === node; + case 212: case 193: return parent.condition === node; } @@ -19192,7 +19456,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 220 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19227,7 +19491,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 225) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19249,7 +19513,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 217) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19269,7 +19533,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19326,7 +19590,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19391,7 +19655,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 210) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } @@ -19422,13 +19686,13 @@ var ts; else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 258) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 259) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 260) { bindAssignmentTargetFlow(p.expression); } } @@ -19528,7 +19792,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { bindInitializedVariableFlow(node); } } @@ -19555,28 +19819,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197: - case 226: - case 229: + case 227: + case 230: case 176: case 161: - case 287: - case 270: + case 288: + case 271: return 1; - case 227: - return 1 | 64; - case 274: - case 230: case 228: + return 1 | 64; + case 275: + case 231: + case 229: case 170: return 1 | 32; - case 261: + case 262: return 1 | 4 | 32; case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } case 150: - case 225: + case 226: case 148: case 151: case 152: @@ -19589,17 +19853,17 @@ var ts; case 184: case 185: return 1 | 4 | 32 | 8 | 16; - case 231: + case 232: return 4; case 147: return node.initializer ? 4 : 0; - case 256: - case 211: + case 257: case 212: case 213: - case 232: + case 214: + case 233: return 2; - case 204: + case 205: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19615,20 +19879,20 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 231: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 262: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197: - case 226: + case 227: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 230: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161: case 176: - case 227: - case 270: - case 287: + case 228: + case 271: + case 288: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 158: case 159: @@ -19640,11 +19904,11 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 274: - case 228: + case 275: + case 229: case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -19660,11 +19924,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 262 ? node : node.body; + if (body && (body.kind === 262 || body.kind === 232)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 242 || stat.kind === 241) { return true; } } @@ -19740,11 +20004,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 260 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -19766,10 +20030,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 231: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 262: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19859,8 +20123,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 262 && + blockScopeContainer.kind !== 231 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19943,14 +20207,14 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 286) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -19982,7 +20246,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 257: return checkStrictModeCatchClause(node); case 186: return checkStrictModeDeleteExpression(node); @@ -19992,7 +20256,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 218: return checkStrictModeWithStatement(node); case 167: seenThisKeyword = true; @@ -20003,22 +20267,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: return bindParameter(node); - case 223: + case 224: case 174: return bindVariableDeclarationOrBindingElement(node); case 147: case 146: - case 271: + case 272: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 287: return bindJSDocProperty(node); - case 257: case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 260: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 259: - case 251: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 261: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 260: + case 252: var root = container; var hasRest = false; while (root.parent) { @@ -20039,7 +20303,7 @@ var ts; case 149: case 148: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: + case 226: return bindFunctionDeclaration(node); case 150: return declareSymbolAndAddToSymbolTable(node, 16384, 0); @@ -20049,12 +20313,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536, 74687); case 158: case 159: - case 274: + case 275: return bindFunctionOrConstructorType(node); case 161: case 170: - case 287: - case 270: + case 288: + case 271: return bindAnonymousDeclaration(node, 2048, "__type"); case 176: return bindObjectLiteralExpression(node); @@ -20067,43 +20331,43 @@ var ts; } break; case 197: - case 226: + case 227: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 228: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 286: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); case 229: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 230: + return bindEnumDeclaration(node); + case 231: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); - case 236: - return bindImportClause(node); - case 241: - return bindExportDeclaration(node); + case 235: + case 238: case 240: + case 244: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 234: + return bindNamespaceExportDeclaration(node); + case 237: + return bindImportClause(node); + case 242: + return bindExportDeclaration(node); + case 241: return bindExportAssignment(node); - case 261: + case 262: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 205: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 232: return updateStrictModeStatementList(node.statements); } } @@ -20131,7 +20395,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20141,17 +20405,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 262) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_5 = node.parent; + if (!ts.isExternalModule(parent_5)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20190,7 +20454,7 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 226 || container.kind === 184) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } @@ -20226,7 +20490,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 227) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -20336,15 +20600,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || + node.kind === 227 || + (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 206 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20362,13 +20626,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180: return computeNewExpression(node, subtreeFlags); - case 230: + case 231: return computeModuleDeclaration(node, subtreeFlags); case 183: return computeParenthesizedExpression(node, subtreeFlags); case 192: return computeBinaryExpression(node, subtreeFlags); - case 207: + case 208: return computeExpressionStatement(node, subtreeFlags); case 144: return computeParameter(node, subtreeFlags); @@ -20376,23 +20640,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184: return computeFunctionExpression(node, subtreeFlags); - case 225: - return computeFunctionDeclaration(node, subtreeFlags); - case 223: - return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeFunctionDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclarationList(node, subtreeFlags); + case 206: + return computeVariableStatement(node, subtreeFlags); + case 220: + return computeLabeledStatement(node, subtreeFlags); + case 227: return computeClassDeclaration(node, subtreeFlags); case 197: return computeClassExpression(node, subtreeFlags); - case 255: - return computeHeritageClause(node, subtreeFlags); case 256: + return computeHeritageClause(node, subtreeFlags); + case 257: return computeCatchClause(node, subtreeFlags); case 199: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -20405,7 +20669,7 @@ var ts; case 151: case 152: return computeAccessor(node, subtreeFlags); - case 234: + case 235: return computeImportEquals(node, subtreeFlags); case 177: return computePropertyAccess(node, subtreeFlags); @@ -20793,25 +21057,25 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: + case 230: + case 261: case 182: case 200: case 201: case 130: transformFlags |= 3; break; - case 246: case 247: case 248: - case 10: case 249: + case 10: case 250: case 251: case 252: + case 253: transformFlags |= 4; break; - case 213: + case 214: transformFlags |= 8; case 12: case 13: @@ -20819,8 +21083,9 @@ var ts; case 15: case 194: case 181: - case 258: + case 259: case 114: + case 202: transformFlags |= 192; break; case 195: @@ -20850,8 +21115,8 @@ var ts; case 164: case 165: case 166: - case 227: case 228: + case 229: case 167: case 168: case 169: @@ -20869,7 +21134,7 @@ var ts; case 196: transformFlags |= 192 | 524288; break; - case 259: + case 260: transformFlags |= 8 | 1048576; break; case 96: @@ -20917,22 +21182,22 @@ var ts; transformFlags |= 192; } break; - case 209: case 210: case 211: case 212: + case 213: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 262: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 216: - case 214: + case 217: case 215: + case 216: transformFlags |= 33554432; break; } @@ -20948,18 +21213,18 @@ var ts; case 180: case 175: return 537396545; - case 230: + case 231: return 574674241; case 144: return 536872257; case 185: return 601249089; case 184: - case 225: - return 601281857; - case 224: - return 546309441; case 226: + return 601281857; + case 225: + return 546309441; + case 227: case 197: return 539358529; case 150: @@ -20981,12 +21246,12 @@ var ts; case 153: case 154: case 155: - case 227: case 228: + case 229: return -3; case 176: return 540087617; - case 256: + case 257: return 537920833; case 172: case 173: @@ -21056,9 +21321,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -21067,6 +21334,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -21089,7 +21357,8 @@ var ts; tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -21183,6 +21452,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var typeofEQFacts = ts.createMap({ @@ -21328,7 +21598,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21423,7 +21693,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -21467,25 +21737,35 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174) { + var errorBindingElement = ts.getAncestor(usage, 174); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + } + else if (declaration.kind === 224) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: - case 213: + case 206: + case 212: + case 214: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: case 213: + case 214: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -21512,6 +21792,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -21525,7 +21814,7 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 144 || @@ -21548,13 +21837,13 @@ var ts; } } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 231: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { + if (location.kind === 262 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -21564,7 +21853,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + ts.getDeclarationOfKind(moduleExports[name], 244)) { break; } } @@ -21572,7 +21861,7 @@ var ts; break loop; } break; - case 229: + case 230: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } @@ -21588,9 +21877,9 @@ var ts; } } break; - case 226: - case 197: case 227: + case 197: + case 228: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -21608,7 +21897,7 @@ var ts; break; case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; @@ -21620,7 +21909,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; @@ -21684,7 +21973,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 234) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -21764,7 +22053,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -21781,10 +22070,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 236) { node = node.parent; } return node; @@ -21794,7 +22083,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 246) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -21898,19 +22187,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: + case 235: return getTargetOfImportEqualsDeclaration(node); - case 236: - return getTargetOfImportClause(node); case 237: + return getTargetOfImportClause(node); + case 238: return getTargetOfNamespaceImport(node); - case 239: - return getTargetOfImportSpecifier(node); - case 243: - return getTargetOfExportSpecifier(node); case 240: + return getTargetOfImportSpecifier(node); + case 244: + return getTargetOfExportSpecifier(node); + case 241: return getTargetOfExportAssignment(node); - case 233: + case 234: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21954,10 +22243,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 241) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 244) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21973,7 +22262,7 @@ var ts; return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 235); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -22270,11 +22559,11 @@ var ts; } } switch (location_1.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230: + case 231: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -22318,7 +22607,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22350,7 +22639,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22423,7 +22712,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22461,7 +22750,7 @@ var ts; meaning = 107455 | 1048576; } else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + entityName.parent.kind === 235) { meaning = 1920; } else { @@ -22556,7 +22845,7 @@ var ts; while (node.kind === 166) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 229) { return getSymbolOfNode(node); } } @@ -22564,7 +22853,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 232 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -22633,9 +22922,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22768,12 +23057,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -22832,7 +23121,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 262 || declaration.parent.kind === 232; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22845,25 +23134,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); @@ -22946,8 +23216,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -23126,6 +23396,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -23138,7 +23412,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -23156,6 +23429,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 134); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -23166,6 +23465,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -23182,27 +23482,27 @@ var ts; switch (node.kind) { case 174: return isDeclarationVisible(node.parent.parent); - case 223: + case 224: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: + case 231: case 227: case 228: - case 225: case 229: - case 234: + case 226: + case 230: + case 235: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147: case 146: case 151: @@ -23217,7 +23517,7 @@ var ts; case 153: case 155: case 144: - case 231: + case 232: case 158: case 159: case 161: @@ -23228,15 +23528,15 @@ var ts; case 165: case 166: return isDeclarationVisible(node.parent); - case 236: case 237: - case 239: + case 238: + case 240: return false; case 143: - case 261: - case 233: + case 262: + case 234: return true; - case 240: + case 241: return false; default: return false; @@ -23245,10 +23545,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 241) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 244) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23326,12 +23626,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: case 224: + case 225: + case 240: case 239: case 238: case 237: - case 236: node = node.parent; break; default: @@ -23350,9 +23650,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); @@ -23487,11 +23784,11 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 213) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -23501,7 +23798,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23539,7 +23836,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (declaration.kind === 259) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23614,7 +23911,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 258) { return type; } return getWidenedType(type); @@ -23642,10 +23939,10 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 241) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -23852,8 +24149,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || + if (node.kind === 227 || node.kind === 197 || + node.kind === 226 || node.kind === 184 || node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { @@ -23863,15 +24160,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 228 || node.kind === 227 || + node.kind === 197 || node.kind === 229) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -24004,7 +24301,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -24033,7 +24330,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 228) { if (declaration.flags & 64) { return false; } @@ -24083,7 +24380,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 286); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24094,7 +24391,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 229); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24126,7 +24423,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24154,7 +24451,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24629,8 +24926,8 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -24901,7 +25198,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 274) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -24912,7 +25209,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 274; } } } @@ -24964,7 +25261,7 @@ var ts; var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -25047,12 +25344,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -25063,7 +25360,7 @@ var ts; case 152: case 184: case 185: - case 274: + case 275: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25335,7 +25632,7 @@ var ts; switch (node.kind) { case 157: return node.typeName; - case 272: + case 273: return node.name; case 199: var expr = node.expression; @@ -25361,7 +25658,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 273) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -25371,7 +25668,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 273) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -25406,9 +25703,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226: case 227: - case 229: + case 228: + case 230: return declaration; } } @@ -25582,8 +25879,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -25693,8 +25991,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -25812,7 +26110,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -25924,7 +26222,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -26047,7 +26345,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { if (!(ts.getModifierFlags(container) & 32) && (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -26066,8 +26364,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: case 264: + case 265: return anyType; case 134: return stringType; @@ -26085,21 +26383,21 @@ var ts; return nullType; case 129: return neverType; - case 289: - return nullType; case 290: - return undefinedType; + return nullType; case 291: + return undefinedType; + case 292: return neverType; case 167: case 98: return getTypeFromThisTypeNode(node); case 171: return getTypeFromLiteralTypeNode(node); - case 288: + case 289: return getTypeFromLiteralTypeNode(node.literal); case 157: - case 272: + case 273: return getTypeFromTypeReference(node); case 156: return booleanType; @@ -26108,29 +26406,29 @@ var ts; case 160: return getTypeFromTypeQueryNode(node); case 162: - case 265: + case 266: return getTypeFromArrayTypeNode(node); case 163: return getTypeFromTupleTypeNode(node); case 164: - case 266: + case 267: return getTypeFromUnionTypeNode(node); case 165: return getTypeFromIntersectionTypeNode(node); case 166: - case 268: case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); case 270: + case 277: + case 278: + case 274: + return getTypeFromTypeNode(node.type); + case 271: return getTypeFromTypeNode(node.literal); case 158: case 159: case 161: - case 287: - case 274: + case 288: + case 275: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168: return getTypeFromTypeOperatorNode(node); @@ -26142,9 +26440,9 @@ var ts; case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 268: return getTypeFromJSDocTupleType(node); - case 275: + case 276: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26293,17 +26591,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -26324,12 +26624,12 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -26340,10 +26640,10 @@ var ts; case 152: case 184: case 185: - case 226: - case 197: case 227: + case 197: case 228: + case 229: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26353,15 +26653,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 228) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 275: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231: + case 262: return false; } node = node.parent; @@ -26371,7 +26680,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 262 || parentKind === 232; } return false; } @@ -26438,7 +26747,7 @@ var ts; case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 258: return isContextSensitive(node.initializer); case 149: case 148: @@ -26494,7 +26803,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -27196,8 +27505,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -27348,7 +27660,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -27557,8 +27869,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27566,8 +27878,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27658,8 +27970,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -27818,7 +28130,7 @@ var ts; case 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 226: case 149: case 148: case 151: @@ -28159,8 +28471,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28276,7 +28588,7 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 224 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; @@ -28374,8 +28686,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -28461,7 +28773,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + return node.parent.kind === 175 || node.parent.kind === 258 ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -28480,9 +28792,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: - return stringType; case 213: + return stringType; + case 214: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192: return getAssignedTypeOfBinaryExpression(parent); @@ -28492,9 +28804,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196: return getAssignedTypeOfSpreadExpression(parent); - case 257: - return getAssignedTypeOfPropertyAssignment(parent); case 258: + return getAssignedTypeOfPropertyAssignment(parent); + case 259: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28517,26 +28829,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 213) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 224 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 224 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 224 && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); @@ -28563,7 +28875,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 254) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28665,8 +28977,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -29208,8 +29520,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || + node.kind === 232 || + node.kind === 262 || node.kind === 147) { return node; } @@ -29279,7 +29591,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 227 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29307,6 +29619,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -29334,7 +29647,7 @@ var ts; flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -29365,7 +29678,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 257) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -29383,8 +29696,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 212 && + ts.getAncestor(symbol.valueDeclaration, 225).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -29474,10 +29787,10 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 150: @@ -29535,9 +29848,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 275) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -29831,8 +30144,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -29902,13 +30215,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { + if (attribute.kind === 251) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251) { + else if (attribute.kind === 252) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -29926,14 +30239,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: + case 224: case 144: case 147: case 146: case 174: return getContextualTypeForInitializerExpression(node); case 185: - case 216: + case 217: return getContextualTypeForReturnExpression(node); case 195: return getContextualTypeForYieldOperand(parent); @@ -29945,22 +30258,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192: return getContextualTypeForBinaryOperand(node); - case 257: case 258: + case 259: return getContextualTypeForObjectLiteralElement(parent); case 175: return getContextualTypeForElementExpression(node); case 193: return getContextualTypeForConditionalOperand(node); - case 202: + case 203: ts.Debug.assert(parent.parent.kind === 194); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183: return getContextualType(parent); - case 252: + case 253: return getContextualType(parent); - case 250: case 251: + case 252: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -30012,8 +30325,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -30156,25 +30469,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 258 || + memberDecl.kind === 259 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 258) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 259); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -30200,7 +30513,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { + else if (memberDecl.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(memberDecl, 2); } @@ -30300,13 +30613,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 253: checkJsxExpression(child); break; - case 246: + case 247: checkJsxElement(child); break; - case 247: + case 248: checkJsxSelfClosingElement(child); break; } @@ -30601,11 +30914,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { + if (node.attributes[i].kind === 251) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251); + ts.Debug.assert(node.attributes[i].kind === 252); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -30624,7 +30937,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -30642,7 +30959,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 177 || node.kind === 224 ? node.name : node.right; if (left.kind === 96) { @@ -30788,7 +31105,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 225) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -30810,7 +31127,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 213 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30906,19 +31223,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -31138,7 +31455,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145) { switch (node.parent.kind) { - case 226: + case 227: case 197: return 1; case 147: @@ -31159,7 +31476,7 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -31180,7 +31497,7 @@ var ts; return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -31217,7 +31534,7 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -31578,7 +31895,7 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: + case 227: case 197: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144: @@ -31688,9 +32005,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 226 : resolvedRequire.flags & 3 - ? 223 + ? 224 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31716,6 +32033,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -31823,7 +32157,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 205) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -31902,7 +32236,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -31948,7 +32282,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -32014,6 +32348,7 @@ var ts; if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -32028,7 +32363,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 205) { checkSourceElement(node.body); } else { @@ -32081,7 +32416,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 238; } } } @@ -32097,6 +32432,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 && expr.kind !== 178) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -32167,8 +32512,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -32182,8 +32527,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -32192,8 +32537,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -32240,7 +32585,7 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { + if (property.kind === 258 || property.kind === 259) { var name_22 = property.name; if (name_22.kind === 142) { checkComputedPropertyName(name_22); @@ -32255,7 +32600,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 259) { return checkDestructuringAssignment(property, type); } else { @@ -32266,7 +32611,7 @@ var ts; error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); } } - else if (property.kind === 259) { + else if (property.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32334,7 +32679,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 259) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -32362,7 +32707,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 260 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32391,8 +32736,8 @@ var ts; case 176: case 187: case 201: + case 248: case 247: - case 246: return true; case 193: return isSideEffectFree(node.whenTrue) && @@ -32826,6 +33171,8 @@ var ts; return checkAssertion(node); case 201: return checkNonNullAssertion(node); + case 202: + return checkMetaProperty(node); case 186: return checkDeleteExpression(node); case 188: @@ -32846,13 +33193,13 @@ var ts; return undefinedWideningType; case 195: return checkYieldExpression(node); - case 252: + case 253: return checkJsxExpression(node); - case 246: - return checkJsxElement(node); case 247: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 248: + return checkJsxSelfClosingElement(node); + case 249: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -32897,7 +33244,7 @@ var ts; return false; } return node.kind === 149 || - node.kind === 225 || + node.kind === 226 || node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -32956,14 +33303,14 @@ var ts; switch (node.parent.kind) { case 185: case 153: - case 225: + case 226: case 184: case 158: case 149: case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -32991,7 +33338,7 @@ var ts; if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || + else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || node.kind === 153 || node.kind === 150 || node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); @@ -33113,7 +33460,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 228) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -33195,7 +33542,7 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 184 && n.kind !== 226) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -33220,7 +33567,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33369,8 +33716,8 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && + if (n.parent.kind !== 228 && + n.parent.kind !== 227 && n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { @@ -33481,11 +33828,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33596,16 +33943,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 228: return 2097152; - case 230: + case 231: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 227: + case 230: return 2097152 | 1048576; - case 234: + case 235: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33617,7 +33964,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -33752,7 +34100,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 227: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -33807,7 +34155,7 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 227: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33840,6 +34188,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33890,28 +34239,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 262: + case 231: checkUnusedModuleMembers(node); break; - case 226: + case 227: case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 228: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: checkUnusedLocalsAndParameters(node); break; case 150: case 184: - case 225: + case 226: case 185: case 149: case 151: @@ -33935,7 +34284,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -33968,9 +34317,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 224 && + (declaration.parent.parent.kind === 213 || + declaration.parent.parent.kind === 214)) { return; } } @@ -34031,7 +34380,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -34039,7 +34388,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 205) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34083,6 +34432,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -34099,6 +34453,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -34108,8 +34478,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -34124,11 +34494,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34136,11 +34506,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34148,7 +34518,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 224 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -34158,15 +34528,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); + var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || + (container.kind === 205 && ts.isFunctionLike(container.parent) || + container.kind === 232 || container.kind === 231 || - container.kind === 230 || - container.kind === 261); + container.kind === 262); if (!namesShareScope) { var name_25 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); @@ -34199,7 +34569,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 144 || + symbol.valueDeclaration.kind === 174) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -34237,19 +34608,19 @@ var ts; } } if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_26 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -34260,7 +34631,7 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34269,7 +34640,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34289,18 +34660,19 @@ var ts; } if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 224 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 144 && right.kind === 224) || + (left.kind === 224 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34346,7 +34718,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 207) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34363,12 +34735,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 225) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34386,7 +34758,7 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { checkForInOrForOfVariableDeclaration(node); } else { @@ -34411,7 +34783,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -34668,7 +35040,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 255 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34680,7 +35052,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 254) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34706,7 +35078,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 220 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -34829,7 +35201,7 @@ var ts; } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -34849,7 +35221,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { + if (declaration.kind === 227 || declaration.kind === 228) { if (!firstDecl) { firstDecl = declaration; } @@ -34882,6 +35254,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -34917,7 +35290,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 227) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -35044,7 +35417,7 @@ var ts; if (!list1 || !list2 || list1.length !== list2.length) { return false; } - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -35102,7 +35475,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35233,6 +35606,7 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; case 183: return evalConstant(e.expression); @@ -35306,6 +35680,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -35326,7 +35701,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 230) { return false; } var enumDeclaration = declaration; @@ -35349,8 +35724,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 || + (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35409,7 +35784,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 227); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35452,22 +35827,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 206: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: case 241: + case 242: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: case 235: + case 236: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174: - case 223: + case 224: var name_27 = node.name; if (ts.isBindingPattern(name_27)) { for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { @@ -35476,12 +35851,12 @@ var ts; } break; } - case 226: - case 229: - case 225: case 227: case 230: + case 226: case 228: + case 231: + case 229: if (isGlobalAugmentation) { return; } @@ -35517,9 +35892,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35540,7 +35915,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 244 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -35567,7 +35942,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { checkImportBinding(importClause.namedBindings); } else { @@ -35618,8 +35993,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35632,7 +36007,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35655,9 +36030,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 ? node.parent : node.parent.parent; + if (container.kind === 231 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -35723,7 +36103,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 226 && declaration.kind !== 149) || !!declaration.body; } } @@ -35734,10 +36114,10 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -35786,71 +36166,71 @@ var ts; return checkIndexedAccessType(node); case 170: return checkMappedType(node); - case 225: + case 226: return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); case 205: + case 232: + return checkBlock(node); + case 206: return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); case 208: - return checkIfStatement(node); + return checkExpressionStatement(node); case 209: - return checkDoStatement(node); + return checkIfStatement(node); case 210: - return checkWhileStatement(node); + return checkDoStatement(node); case 211: - return checkForStatement(node); + return checkWhileStatement(node); case 212: - return checkForInStatement(node); + return checkForStatement(node); case 213: - return checkForOfStatement(node); + return checkForInStatement(node); case 214: + return checkForOfStatement(node); case 215: - return checkBreakOrContinueStatement(node); case 216: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 217: - return checkWithStatement(node); + return checkReturnStatement(node); case 218: - return checkSwitchStatement(node); + return checkWithStatement(node); case 219: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 220: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 221: + return checkThrowStatement(node); + case 222: return checkTryStatement(node); - case 223: + case 224: return checkVariableDeclaration(node); case 174: return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 228: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 229: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 230: + return checkEnumDeclaration(node); + case 231: return checkModuleDeclaration(node); - case 235: + case 236: return checkImportDeclaration(node); - case 234: + case 235: return checkImportEqualsDeclaration(node); - case 241: + case 242: return checkExportDeclaration(node); - case 240: + case 241: return checkExportAssignment(node); - case 206: + case 207: checkGrammarStatementInAmbientContext(node); return; - case 222: + case 223: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 245: return checkMissingDeclaration(node); } } @@ -35893,6 +36273,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -35912,6 +36293,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -35956,7 +36341,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 218 && node.parent.statement === node) { return true; } node = node.parent; @@ -35978,14 +36363,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; case 197: @@ -35993,8 +36378,8 @@ var ts; if (className) { copySymbol(location.symbol, meaning); } - case 226: case 227: + case 228: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } @@ -36039,10 +36424,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143: - case 226: case 227: case 228: case 229: + case 230: return true; } } @@ -36051,7 +36436,7 @@ var ts; while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -36078,10 +36463,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 235) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 241) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -36105,11 +36490,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + var importEqualsDeclaration = ts.getAncestor(entityName, 235); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -36156,10 +36541,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 251) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156) { @@ -36168,7 +36553,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 262) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36221,7 +36606,7 @@ var ts; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 236 || node.parent.kind === 242) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36243,7 +36628,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 259) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36294,7 +36679,7 @@ var ts; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + if (expr.parent.kind === 214) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -36302,7 +36687,7 @@ var ts; var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 258) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -36413,7 +36798,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -36451,7 +36836,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36491,16 +36876,16 @@ var ts; return true; } switch (node.kind) { - case 234: - case 236: + case 235: case 237: - case 239: - case 243: + case 238: + case 240: + case 244: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241: + case 242: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 241: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -36510,7 +36895,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36561,7 +36946,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 261) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36655,9 +37040,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36770,15 +37155,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36797,7 +37182,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 262); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -36974,7 +37359,7 @@ var ts; } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 230 && node.parent.kind === 227) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -37000,7 +37385,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -37023,7 +37408,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144) { @@ -37058,7 +37443,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144) { @@ -37073,13 +37458,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -37089,14 +37474,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { + if (node.kind !== 227) { if (node.kind !== 149 && node.kind !== 147 && node.kind !== 151 && node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37138,7 +37523,7 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 236 || node.kind === 235) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { @@ -37168,29 +37553,29 @@ var ts; case 149: case 148: case 155: - case 230: + case 231: + case 236: case 235: - case 234: + case 242: case 241: - case 240: case 184: case 185: case 144: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 232 || node.parent.kind === 262) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); case 226: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 116); case 228: - return true; + case 206: case 229: + return true; + case 230: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -37204,7 +37589,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149: - case 225: + case 226: case 184: case 185: if (!node.asteriskToken) { @@ -37410,7 +37795,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || + ts.Debug.assert(node.kind === 226 || node.kind === 184 || node.kind === 149); if (ts.isInAmbientContext(node)) { @@ -37437,14 +37822,14 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 260) { continue; } var name_30 = prop.name; if (name_30.kind === 142) { checkGrammarComputedPropertyName(name_30); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { @@ -37456,7 +37841,7 @@ var ts; } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 258 || prop.kind === 259) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_30.kind === 8) { checkGrammarNumericLiteral(name_30); @@ -37505,7 +37890,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 252) { continue; } var jsxAttr = attr; @@ -37517,7 +37902,7 @@ var ts; return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 253 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37526,7 +37911,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 225) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37534,20 +37919,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -37631,7 +38016,7 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } else if (node.parent.kind === 161) { @@ -37645,9 +38030,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 220: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 215 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -37655,8 +38040,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 219: + if (node.kind === 216 && !node.label) { return false; } break; @@ -37669,13 +38054,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 216 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 215 + var message = node.kind === 216 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -37701,7 +38086,7 @@ var ts; expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37758,15 +38143,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: case 209: case 210: - case 217: case 211: + case 218: case 212: case 213: + case 214: return false; - case 219: + case 220: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -37781,6 +38166,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -37821,7 +38213,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37842,13 +38234,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 228 || + node.kind === 229 || + node.kind === 236 || node.kind === 235 || - node.kind === 234 || + node.kind === 242 || node.kind === 241 || - node.kind === 240 || - node.kind === 233 || + node.kind === 234 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -37857,7 +38249,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 205) { + if (ts.isDeclaration(decl) || decl.kind === 206) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -37876,7 +38268,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 205 || node.parent.kind === 232 || node.parent.kind === 262) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -37887,8 +38279,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -37933,31 +38339,31 @@ var ts; _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230] = [ + _a[231] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231] = [ + _a[232] = [ { name: "statements", test: ts.isStatement } ], - _a[234] = [ + _a[235] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245] = [ + _a[246] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260] = [ + _a[261] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -37983,11 +38389,11 @@ var ts; } var result = initial; switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: - case 293: + case 223: + case 294: break; case 142: result = reduceNode(node.expression, cbNode, result); @@ -38128,72 +38534,72 @@ var ts; result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 202: + case 203: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 205: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 206: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 208: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 211: + case 218: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 212: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: case 213: + case 214: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 217: + case 221: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 219: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 222: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 224: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 225: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 226: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38202,7 +38608,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38210,92 +38616,92 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232: + case 233: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 237: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 239: case 243: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 240: + case 244: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240: + case 241: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: case 248: + case 249: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249: + case 250: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 251: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; case 252: result = reduceNode(node.expression, cbNode, result); break; case 253: result = reduceNode(node.expression, cbNode, result); + break; case 254: + result = reduceNode(node.expression, cbNode, result); + case 255: result = reduceNodes(node.statements, cbNodes, result); break; - case 255: + case 256: result = reduceNodes(node.types, cbNodes, result); break; - case 256: + case 257: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 258: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 259: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 260: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 262: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 295: result = reduceNode(node.expression, cbNode, result); break; default: @@ -38436,10 +38842,10 @@ var ts; return node; } switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: + case 223: return node; case 142: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); @@ -38507,101 +38913,101 @@ var ts; return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); case 199: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 202: + case 203: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 204: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 205: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 206: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 221: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 222: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 226: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 227: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232: + case 233: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 243: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 244: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 259: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 260: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 261: + case 262: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 295: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -38689,7 +39095,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -39093,15 +39499,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: + case 262: + case 233: case 232: - case 231: - case 204: + case 205: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 227: case 226: - case 225: if (ts.hasModifier(node, 2)) { break; } @@ -39126,13 +39532,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 240: - return visitExportAssignment(node); case 241: + return visitExportAssignment(node); + case 242: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39142,11 +39548,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || + if (node.kind === 242 || node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + node.kind === 237 || + (node.kind === 235 && + node.moduleReference.kind === 246)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39170,7 +39576,7 @@ var ts; case 152: case 149: return visitorWorker(node); - case 203: + case 204: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39227,18 +39633,18 @@ var ts; case 171: case 155: case 145: - case 228: + case 229: case 147: return undefined; case 150: return visitConstructor(node); - case 227: + case 228: return ts.createNotEmittedStatement(node); - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); - case 255: + case 256: return visitHeritageClause(node); case 199: return visitExpressionWithTypeArguments(node); @@ -39248,7 +39654,7 @@ var ts; return visitGetAccessor(node); case 152: return visitSetAccessor(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -39267,15 +39673,15 @@ var ts; return visitNewExpression(node); case 201: return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); case 230: + return visitEnumDeclaration(node); + case 206: + return visitVariableStatement(node); + case 224: + return visitVariableDeclaration(node); + case 231: return visitModuleDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39429,7 +39835,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39714,7 +40120,7 @@ var ts; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: + case 227: case 197: return ts.getFirstConstructorWithBody(node) !== undefined; case 149: @@ -39732,7 +40138,7 @@ var ts; return serializeTypeNode(node.type); case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: + case 227: case 197: case 149: return ts.createIdentifier("Function"); @@ -39789,6 +40195,9 @@ var ts; } switch (node.kind) { case 104: + case 137: + case 94: + case 129: return ts.createVoidZero(); case 166: return serializeTypeNode(node.type); @@ -39827,29 +40236,7 @@ var ts; return serializeTypeReferenceNode(node); case 165: case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } + return serializeUnionOrIntersectionType(node); case 160: case 168: case 169: @@ -39864,6 +40251,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -40190,7 +40603,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 230) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -40250,8 +40663,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -40273,13 +40686,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + if (body.kind !== 232) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 231) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40299,7 +40712,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 238) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40434,15 +40847,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(259); + context.enableEmitNotification(231); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 230; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -40515,9 +40928,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 262) { + var substitute = (applicableSubstitutions & 2 && container.kind === 231) || + (applicableSubstitutions & 8 && container.kind === 230); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -40632,11 +41045,11 @@ var ts; return visitObjectLiteralExpression(node); case 192: return visitBinaryExpression(node, noDestructuringValue); - case 223: + case 224: return visitVariableDeclaration(node); - case 213: + case 214: return visitForOfStatement(node); - case 211: + case 212: return visitForStatement(node); case 188: return visitVoidExpression(node); @@ -40648,7 +41061,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152: return visitSetAccessorDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -40656,7 +41069,7 @@ var ts; return visitArrowFunction(node); case 144: return visitParameter(node); - case 207: + case 208: return visitExpressionStatement(node); case 183: return visitParenthesizedExpression(node, noDestructuringValue); @@ -40669,7 +41082,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259) { + if (e.kind === 260) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40681,7 +41094,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 258) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40854,11 +41267,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: - return visitJsxElement(node, false); case 247: + return visitJsxElement(node, false); + case 248: return visitJsxSelfClosingElement(node, false); - case 252: + case 253: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40868,11 +41281,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 253: return visitJsxExpression(node); - case 246: - return visitJsxElement(node, true); case 247: + return visitJsxElement(node, true); + case 248: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -40926,7 +41339,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 252) { + else if (node.kind === 253) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -40991,7 +41407,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 247) { return getTagName(node.openingElement); } else { @@ -41310,7 +41726,7 @@ var ts; return visitAwaitExpression(node); case 149: return visitMethodDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -41409,7 +41825,7 @@ var ts; context.enableSubstitution(179); context.enableSubstitution(177); context.enableSubstitution(178); - context.enableEmitNotification(226); + context.enableEmitNotification(227); context.enableEmitNotification(149); context.enableEmitNotification(151); context.enableEmitNotification(152); @@ -41465,7 +41881,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 + return kind === 227 || kind === 150 || kind === 149 || kind === 151 @@ -41604,15 +42020,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -41622,178 +42030,104 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 217 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); case 144: return visitParameter(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 185: return visitArrowFunction(node); case 184: return visitFunctionExpression(node); - case 223: + case 224: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 225: return visitVariableDeclarationList(node); case 219: + return visitSwitchStatement(node); + case 233: + return visitCaseBlock(node); + case 205: + return visitBlock(node, false); + case 216: + case 215: + return visitBreakOrContinueStatement(node); + case 220: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); + return visitDoOrWhileStatement(node, undefined); case 212: - return visitForInStatement(node); + return visitForStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForInStatement(node, undefined); + case 214: + return visitForOfStatement(node, undefined); + case 208: return visitExpressionStatement(node); case 176: return visitObjectLiteralExpression(node); - case 256: + case 257: return visitCatchClause(node); - case 258: + case 259: return visitShorthandPropertyAssignment(node); + case 142: + return visitComputedPropertyName(node); case 175: return visitArrayLiteralExpression(node); case 179: @@ -41818,51 +42152,80 @@ var ts; case 196: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 202: + return visitMetaProperty(node); case 149: return visitMethodDeclaration(node); - case 205: + case 151: + case 152: + return visitAccessorDeclaration(node); + case 206: return visitVariableStatement(node); + case 217: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0, 0); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -41878,13 +42241,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; + var jump = node.kind === 216 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 216) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -41894,7 +42257,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 216) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -41993,6 +42356,9 @@ var ts; } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); @@ -42000,6 +42366,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -42020,23 +42388,26 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { ts.setEmitFlags(block, 1536); @@ -42044,17 +42415,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 217) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 209) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 205) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -42062,8 +42433,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -42083,9 +42454,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression @@ -42100,17 +42470,17 @@ var ts; statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -42206,21 +42576,53 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 185: + return statements; + case 149: + case 151: + case 152: + newTarget = ts.createVoidZero(); + break; + case 150: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 226: + case 184: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 204: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151: case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150: @@ -42234,26 +42636,29 @@ var ts; function transformSemicolonClassElementToStatement(member) { return ts.createEmptyStatement(member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); ts.setEmitFlags(statement, 1536); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -42262,7 +42667,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -42270,7 +42675,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -42286,35 +42691,69 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -42361,6 +42800,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } @@ -42374,6 +42814,21 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { case 183: @@ -42398,9 +42853,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -42417,49 +42875,54 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -42475,48 +42938,51 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; @@ -42579,31 +43045,53 @@ var ts; ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); ts.setEmitFlags(forStatement, 256); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210: + case 211: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212: + return visitForStatement(node, outermostLabeledStatement); + case 213: + return visitForInStatement(node, outermostLabeledStatement); + case 214: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -42627,14 +43115,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -42643,11 +43133,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: case 212: case 213: + case 214: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 225) { loopInitializer = initializer; } break; @@ -42674,7 +43164,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -42686,11 +43176,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, undefined, true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], undefined, true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -42749,19 +43241,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -42875,17 +43366,17 @@ var ts; case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: - expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + case 149: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; case 258: - expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + case 259: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -42907,21 +43398,31 @@ var ts; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -42929,21 +43430,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; + } function visitShorthandPropertyAssignment(node) { return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; + } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -42955,25 +43478,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -43071,21 +43596,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -43103,7 +43641,7 @@ var ts; context.enableEmitNotification(152); context.enableEmitNotification(185); context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } function onSubstituteNode(emitContext, node) { @@ -43129,9 +43667,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174: - case 226: - case 229: - case 223: + case 227: + case 230: + case 224: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43157,8 +43695,7 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { + && hierarchyFacts & 16) { return ts.createIdentifier("_this", node); } return node; @@ -43175,7 +43712,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { return false; } var statementExpression = statement.expression; @@ -43206,7 +43743,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; @@ -43283,13 +43820,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 218: - return visitSwitchStatement(node); case 219: + return visitSwitchStatement(node); + case 220: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43297,24 +43834,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); case 151: case 152: return visitAccessorDeclaration(node); - case 205: + case 206: return visitVariableStatement(node); - case 211: - return visitForStatement(node); case 212: + return visitForStatement(node); + case 213: return visitForInStatement(node); - case 215: - return visitBreakStatement(node); - case 214: - return visitContinueStatement(node); case 216: + return visitBreakStatement(node); + case 215: + return visitContinueStatement(node); + case 217: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43352,7 +43889,7 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -43539,10 +44076,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -43604,7 +44141,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -43664,10 +44201,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -43710,35 +44247,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 205: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 212: + return transformAndEmitForStatement(node); + case 213: return transformAndEmitForInStatement(node); - case 214: - return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 221: + return transformAndEmitThrowStatement(node); + case 222: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -43758,7 +44295,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_39 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_39, variable.name); + hoistVariableDeclaration(name_39); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -43788,7 +44327,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -44022,7 +44561,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 255 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44032,7 +44571,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 254) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44153,12 +44692,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_6 = ts.getMutableClone(name_39); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_40 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_40) { + var clone_7 = ts.getMutableClone(name_40); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -44768,41 +45307,41 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)]), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)]), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ]), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -44827,15 +45366,40 @@ var ts; var ts; (function (ts) { function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249); + context.enableEmitNotification(250); + context.enableEmitNotification(248); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177); - context.enableSubstitution(257); + context.enableSubstitution(258); return transformSourceFile; function transformSourceFile(node) { return node; } + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249: + case 250: + case 248: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -44892,8 +45456,8 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); + context.enableSubstitution(259); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var currentSourceFile; @@ -44931,14 +45495,7 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; return ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ @@ -44952,6 +45509,36 @@ var ts; ]))) ], node.statements)); } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], undefined, true)); + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ], node.statements)); + } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; var unaliasedModuleNames = []; @@ -45011,23 +45598,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return visitExportDeclaration(node); - case 240: + case 241: return visitExportAssignment(node); - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return node; @@ -45225,7 +45812,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -45257,10 +45844,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45368,7 +45955,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -45428,7 +46015,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -45437,8 +46024,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_40 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); + var name_41 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_41), node); } } } @@ -45502,7 +46089,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -45519,7 +46105,7 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableEmitNotification(261); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var exportFunctionsMap = ts.createMap(); @@ -45619,7 +46205,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 242 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -45642,7 +46228,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 242) { continue; } var exportDecl = externalImport; @@ -45694,15 +46280,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 236: if (!entry.importClause) { break; } - case 234: + case 235: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 242: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -45724,13 +46310,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return undefined; - case 240: + case 241: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -45851,7 +46437,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 262 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -45873,7 +46459,7 @@ var ts; : preventSubstitution(ts.createAssignment(name, value, location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -45906,10 +46492,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -46008,43 +46594,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitForStatement(node); case 213: + return visitForInStatement(node); + case 214: return visitForOfStatement(node); - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 219: + case 220: return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); case 218: + return visitWithStatement(node); + case 219: return visitSwitchStatement(node); - case 232: + case 233: return visitCaseBlock(node); - case 253: - return visitCaseClause(node); case 254: + return visitCaseClause(node); + case 255: return visitDefaultClause(node); - case 221: + case 222: return visitTryStatement(node); - case 256: + case 257: return visitCatchClause(node); - case 204: + case 205: return visitBlock(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46172,7 +46758,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 262; } else { return false; @@ -46187,7 +46773,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46299,7 +46885,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46327,7 +46913,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.enableEmitNotification(262); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -46352,9 +46938,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234: + case 235: return undefined; - case 240: + case 241: return visitExportAssignment(node); } return node; @@ -46663,7 +47249,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 236); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -46735,10 +47321,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 224) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -46749,7 +47335,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 236) { moduleElementEmitInfo.isVisible = true; } else { @@ -46757,12 +47343,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -46933,7 +47519,7 @@ var ts; } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -47050,9 +47636,9 @@ var ts; var count = 0; while (true) { count++; - var name_41 = baseName + "_" + count; - if (!(name_41 in currentIdentifiers)) { - return name_41; + var name_42 = baseName + "_" + count; + if (!(name_42 in currentIdentifiers)) { + return name_42; } } } @@ -47096,10 +47682,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 235 || + (node.parent.kind === 262 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47108,7 +47694,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 236) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47126,30 +47712,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); - case 227: - return writeInterfaceDeclaration(node); case 226: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 206: + return writeVariableStatement(node); case 228: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 227: + return writeClassDeclaration(node); case 229: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 230: + return writeEnumDeclaration(node); + case 231: return writeModuleDeclaration(node); - case 234: - return writeImportEqualsDeclaration(node); case 235: + return writeImportEqualsDeclaration(node); + case 236: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 262) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47157,7 +47743,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 228 && !noDeclare) { write("declare "); } } @@ -47207,7 +47793,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47230,7 +47816,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 238) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47247,13 +47833,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 235) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 231) { moduleSpecifier = parent.name; } else { @@ -47321,7 +47907,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 232) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -47419,10 +48005,10 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154: @@ -47436,17 +48022,17 @@ var ts; if (ts.hasModifier(node.parent, 32)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 227) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 225: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47483,7 +48069,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 227) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -47566,7 +48152,7 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -47589,7 +48175,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 224) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47604,7 +48190,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47764,13 +48350,13 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 226) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 226) { write("function "); writeTextOfNode(currentText, node.name); } @@ -47864,7 +48450,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47877,7 +48463,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 226: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47954,7 +48540,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47966,7 +48552,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 225: + case 226: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -48018,19 +48604,19 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: - case 227: case 226: - case 228: - case 229: - return emitModuleElement(node, isModuleElementVisible(node)); - case 205: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: case 235: + case 228: + case 227: + case 229: + case 230: + return emitModuleElement(node, isModuleElementVisible(node)); + case 206: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 236: return emitModuleElement(node, !node.importClause); - case 241: + case 242: return emitExportDeclaration(node); case 150: case 149: @@ -48046,11 +48632,11 @@ var ts; case 147: case 146: return emitPropertyDeclaration(node); - case 260: - return emitEnumMemberDeclaration(node); - case 240: - return emitExportAssignment(node); case 261: + return emitEnumMemberDeclaration(node); + case 241: + return emitExportAssignment(node); + case 262: return emitSourceFile(node); } } @@ -48267,7 +48853,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -48280,7 +48866,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -48424,7 +49010,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 294; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -48438,7 +49024,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 225) { declarationListContainerEnd = end; } } @@ -48794,7 +49380,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 261: + case 262: return emitSourceFile(node); } } @@ -48917,119 +49503,119 @@ var ts; return emitArrayBindingPattern(node); case 174: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); case 203: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 204: - return emitBlock(node); + return emitSemicolonClassElement(); case 205: - return emitVariableStatement(node); + return emitBlock(node); case 206: - return emitEmptyStatement(); + return emitVariableStatement(node); case 207: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 208: - return emitIfStatement(node); + return emitExpressionStatement(node); case 209: - return emitDoStatement(node); + return emitIfStatement(node); case 210: - return emitWhileStatement(node); + return emitDoStatement(node); case 211: - return emitForStatement(node); + return emitWhileStatement(node); case 212: - return emitForInStatement(node); + return emitForStatement(node); case 213: - return emitForOfStatement(node); + return emitForInStatement(node); case 214: - return emitContinueStatement(node); + return emitForOfStatement(node); case 215: - return emitBreakStatement(node); + return emitContinueStatement(node); case 216: - return emitReturnStatement(node); + return emitBreakStatement(node); case 217: - return emitWithStatement(node); + return emitReturnStatement(node); case 218: - return emitSwitchStatement(node); + return emitWithStatement(node); case 219: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 220: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 221: - return emitTryStatement(node); + return emitThrowStatement(node); case 222: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 223: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 226: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 227: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 231: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 232: + return emitModuleBlock(node); + case 233: return emitCaseBlock(node); - case 234: - return emitImportEqualsDeclaration(node); case 235: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 236: - return emitImportClause(node); + return emitImportDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportClause(node); case 238: - return emitNamedImports(node); + return emitNamespaceImport(node); case 239: - return emitImportSpecifier(node); + return emitNamedImports(node); case 240: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 241: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 242: - return emitNamedExports(node); + return emitExportDeclaration(node); case 243: - return emitExportSpecifier(node); + return emitNamedExports(node); case 244: - return; + return emitExportSpecifier(node); case 245: + return; + case 246: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); case 249: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 252: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxExpression(node); case 254: - return emitDefaultClause(node); + return emitCaseClause(node); case 255: - return emitHeritageClause(node); + return emitDefaultClause(node); case 256: - return emitCatchClause(node); + return emitHeritageClause(node); case 257: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 259: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 260: + return emitSpreadAssignment(node); + case 261: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -49106,14 +49692,14 @@ var ts; return emitAsExpression(node); case 201: return emitNonNullExpression(node); - case 246: - return emitJsxElement(node); + case 202: + return emitMetaProperty(node); case 247: + return emitJsxElement(node); + case 248: return emitJsxSelfClosingElement(node); - case 294: + case 295: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); } } function emitNumericLiteral(node) { @@ -49558,6 +50144,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -49600,27 +50191,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 209) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -49630,7 +50221,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49642,7 +50233,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49652,7 +50243,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49662,11 +50253,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 225) { emit(node); } else { @@ -49693,7 +50284,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -49717,9 +50308,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -49895,7 +50489,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 231) { write("."); emit(body.name); body = body.body; @@ -50046,6 +50640,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -50245,8 +50842,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -50375,6 +50972,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -50555,21 +51160,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_42 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_42)) { + var name_43 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_43)) { tempFlags |= flags; - return name_42; + return name_43; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_43 = count < 26 + var name_44 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_43)) { - return name_43; + if (isUniqueName(name_44)) { + return name_44; } } } @@ -50603,22 +51208,32 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 231: case 230: - case 229: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 236: + case 242: return generateNameForImportOrExportDeclaration(node); - case 225: case 226: - case 240: + case 227: + case 241: return generateNameForExportDefault(); case 197: return generateNameForClassExpression(); + case 149: + case 151: + case 152: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } @@ -50649,11 +51264,14 @@ var ts; } return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } function getGeneratedIdentifier(name) { if (name.autoGenerateKind === 4) { var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { var autoGenerateId = name.autoGenerateId; @@ -50722,7 +51340,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -50905,10 +51524,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_44 = names_1[_i]; - var result = name_44 in cache - ? cache[name_44] - : cache[name_44] = loader(name_44, containingFile); + var name_45 = names_1[_i]; + var result = name_45 in cache + ? cache[name_45] + : cache[name_45] = loader(name_45, containingFile); resolutions.push(result); } return resolutions; @@ -50933,6 +51552,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -50945,7 +51565,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -50981,6 +51602,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -51187,7 +51809,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -51345,42 +51967,42 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: - case 223: + case 226: + case 224: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 235: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 241: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 256: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 228: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182: @@ -51398,23 +52020,23 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: + case 227: case 149: case 148: case 150: case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: + case 226: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 206: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 206); } break; case 147: @@ -51526,7 +52148,7 @@ var ts; && !file.isDeclarationFile) { var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); + var importDecl = ts.createSynthesizedNode(236); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -51544,9 +52166,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 236: case 235: - case 234: - case 241: + case 242: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51558,7 +52180,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 231: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -52182,32 +52804,32 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 144: - case 223: + case 224: case 174: case 147: case 146: - case 257: case 258: - case 260: + case 259: + case 261: case 149: case 148: case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 256: + case 257: return 1; case 143: - case 227: case 228: + case 229: case 161: return 2; - case 226: - case 229: - return 1 | 2; + case 227: case 230: + return 1 | 2; + case 231: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -52217,21 +52839,21 @@ var ts; else { return 4; } - case 238: case 239: - case 234: - case 235: case 240: + case 235: + case 236: case 241: + case 242: return 1 | 2 | 4; - case 261: + case 262: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240) { + if (node.parent.kind === 241) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -52255,7 +52877,7 @@ var ts; ts.Debug.assert(node.kind === 70); if (node.parent.kind === 141 && node.parent.right === node && - node.parent.parent.kind === 234) { + node.parent.parent.kind === 235) { return 1 | 2 | 4; } return 4; @@ -52289,10 +52911,10 @@ var ts; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 255) { + if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 256) { var decl = root.parent.parent.parent; - return (decl.kind === 226 && root.parent.parent.token === 107) || - (decl.kind === 227 && root.parent.parent.token === 84); + return (decl.kind === 227 && root.parent.parent.token === 107) || + (decl.kind === 228 && root.parent.parent.token === 84); } return false; } @@ -52323,7 +52945,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 220 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -52333,13 +52955,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 215 || node.parent.kind === 214) && + (node.parent.kind === 216 || node.parent.kind === 215) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 219 && + node.parent.kind === 220 && node.parent.label === node; } function isLabelName(node) { @@ -52355,7 +52977,7 @@ var ts; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 && node.parent.name === node; + return node.parent.kind === 231 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -52368,13 +52990,13 @@ var ts; switch (node.parent.kind) { case 147: case 146: - case 257: - case 260: + case 258: + case 261: case 149: case 148: case 151: case 152: - case 230: + case 231: return node.parent.name === node; case 178: return node.parent.argumentExpression === node; @@ -52422,17 +53044,17 @@ var ts; return undefined; } switch (node.kind) { - case 261: + case 262: case 149: case 148: - case 225: + case 226: case 184: case 151: case 152: - case 226: case 227: - case 229: + case 228: case 230: + case 231: return node; } } @@ -52440,22 +53062,22 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261: + case 262: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230: + case 231: return ts.ScriptElementKind.moduleElement; - case 226: + case 227: case 197: return ts.ScriptElementKind.classElement; - case 227: return ts.ScriptElementKind.interfaceElement; - case 228: return ts.ScriptElementKind.typeElement; - case 229: return ts.ScriptElementKind.enumElement; - case 223: + case 228: return ts.ScriptElementKind.interfaceElement; + case 229: return ts.ScriptElementKind.typeElement; + case 230: return ts.ScriptElementKind.enumElement; + case 224: return getKindOfVariableDeclaration(node); case 174: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); case 185: - case 225: + case 226: case 184: return ts.ScriptElementKind.functionElement; case 151: return ts.ScriptElementKind.memberGetAccessorElement; @@ -52471,15 +53093,15 @@ var ts; case 153: return ts.ScriptElementKind.callSignatureElement; case 150: return ts.ScriptElementKind.constructorImplementationElement; case 143: return ts.ScriptElementKind.typeParameterElement; - case 260: return ts.ScriptElementKind.enumMemberElement; + case 261: return ts.ScriptElementKind.enumMemberElement; case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234: - case 239: - case 236: - case 243: + case 235: + case 240: case 237: + case 244: + case 238: return ts.ScriptElementKind.alias; - case 285: + case 286: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -52551,19 +53173,19 @@ var ts; return false; } switch (n.kind) { - case 226: case 227: - case 229: + case 228: + case 230: case 176: case 172: case 161: - case 204: - case 231: + case 205: case 232: - case 238: - case 242: + case 233: + case 239: + case 243: return nodeEndsWith(n, 17, sourceFile); - case 256: + case 257: return isCompletedNode(n.block, sourceFile); case 180: if (!n.arguments) { @@ -52579,7 +53201,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 149: case 148: @@ -52593,14 +53215,14 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 230: + case 231: return n.body && isCompletedNode(n.body, sourceFile); - case 208: + case 209: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207: + case 208: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); case 175: @@ -52614,15 +53236,15 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 253: case 254: + case 255: return false; - case 211: case 212: case 213: - case 210: + case 214: + case 211: return isCompletedNode(n.statement, sourceFile); - case 209: + case 210: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); @@ -52642,10 +53264,10 @@ var ts; case 194: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202: + case 203: return ts.nodeIsPresent(n.literal); - case 241: - case 235: + case 242: + case 236: return ts.nodeIsPresent(n.moduleSpecifier); case 190: return isCompletedNode(n.operand, sourceFile); @@ -52694,7 +53316,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 292 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 293 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -52749,8 +53371,8 @@ var ts; } } } - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; if (ts.isJSDocNode(child)) { continue; } @@ -52814,7 +53436,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); @@ -52829,7 +53451,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261); + ts.Debug.assert(startNode !== undefined || n.kind === 262); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -52874,13 +53496,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 252) { + if (token.kind === 26 && token.parent.kind === 253) { return true; } - if (token && token.kind === 17 && token.parent.kind === 252) { + if (token && token.kind === 17 && token.parent.kind === 253) { return true; } - if (token.kind === 26 && token.parent.kind === 249) { + if (token.kind === 26 && token.parent.kind === 250) { return true; } return false; @@ -52974,7 +53596,7 @@ var ts; if (node.kind === 157 || node.kind === 179) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 || node.kind === 227) { + if (ts.isFunctionLike(node) || node.kind === 227 || node.kind === 228) { return node.typeParameters; } return undefined; @@ -53047,11 +53669,11 @@ var ts; node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 213 && + if (node.parent.kind === 214 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 ? node.parent.parent : node.parent)) { return true; } } @@ -53268,7 +53890,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 || location.parent.kind === 243) && + (location.parent.kind === 240 || location.parent.kind === 244) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -53325,6 +53947,10 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -53373,15 +53999,15 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205: + case 206: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223: + case 224: case 147: case 146: return spanInVariableDeclaration(node); case 144: return spanInParameterDeclaration(node); - case 225: + case 226: case 149: case 148: case 151: @@ -53390,72 +54016,72 @@ var ts; case 184: case 185: return spanInFunctionDeclaration(node); - case 204: + case 205: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 231: + case 232: return spanInBlock(node); - case 256: + case 257: return spanInBlock(node.block); - case 207: - return textSpan(node.expression); - case 216: - return textSpan(node.getChildAt(0), node.expression); - case 210: - return textSpanEndingAtNextToken(node, node.expression); - case 209: - return spanInNode(node.statement); - case 222: - return textSpan(node.getChildAt(0)); case 208: - return textSpanEndingAtNextToken(node, node.expression); - case 219: - return spanInNode(node.statement); - case 215: - case 214: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 217: + return textSpan(node.getChildAt(0), node.expression); case 211: - return spanInForStatement(node); - case 212: return textSpanEndingAtNextToken(node, node.expression); - case 213: - return spanInInitializerOfForLike(node); - case 218: + case 210: + return spanInNode(node.statement); + case 223: + return textSpan(node.getChildAt(0)); + case 209: return textSpanEndingAtNextToken(node, node.expression); - case 253: - case 254: - return spanInNode(node.statements[0]); - case 221: - return spanInBlock(node.tryBlock); case 220: + return spanInNode(node.statement); + case 216: + case 215: + return textSpan(node.getChildAt(0), node.label); + case 212: + return spanInForStatement(node); + case 213: + return textSpanEndingAtNextToken(node, node.expression); + case 214: + return spanInInitializerOfForLike(node); + case 219: + return textSpanEndingAtNextToken(node, node.expression); + case 254: + case 255: + return spanInNode(node.statements[0]); + case 222: + return spanInBlock(node.tryBlock); + case 221: return textSpan(node, node.expression); - case 240: - return textSpan(node, node.expression); - case 234: - return textSpan(node, node.moduleReference); - case 235: - return textSpan(node, node.moduleSpecifier); case 241: + return textSpan(node, node.expression); + case 235: + return textSpan(node, node.moduleReference); + case 236: return textSpan(node, node.moduleSpecifier); - case 230: + case 242: + return textSpan(node, node.moduleSpecifier); + case 231: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 226: - case 229: - case 260: + case 227: + case 230: + case 261: case 174: return textSpan(node); - case 217: + case 218: return spanInNode(node.statement); case 145: return spanInNodeArray(node.parent.decorators); case 172: case 173: return spanInBindingPattern(node); - case 227: case 228: + case 229: return undefined; case 24: case 1: @@ -53491,8 +54117,8 @@ var ts; } if ((node.kind === 70 || node.kind == 196 || - node.kind === 257 || - node.kind === 258) && + node.kind === 258 || + node.kind === 259) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } @@ -53511,12 +54137,12 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209: + case 210: return spanInPreviousNode(node); case 145: return spanInNode(node.parent); - case 211: - case 213: + case 212: + case 214: return textSpan(node); case 192: if (node.parent.operatorToken.kind === 25) { @@ -53530,7 +54156,7 @@ var ts; break; } } - if (node.parent.kind === 257 && + if (node.parent.kind === 258 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); @@ -53541,7 +54167,7 @@ var ts; if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 223 || + if ((node.parent.kind === 224 || node.parent.kind === 144)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || @@ -53571,7 +54197,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 212) { + if (variableDeclaration.parent.parent.kind === 213) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -53579,7 +54205,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 213) { + variableDeclaration.parent.parent.kind === 214) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -53611,7 +54237,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 226 && functionDeclaration.kind !== 150); + (functionDeclaration.parent.kind === 227 && functionDeclaration.kind !== 150); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -53631,22 +54257,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230: + case 231: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 210: - case 208: - case 212: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 211: + case 209: case 213: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 212: + case 214: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224) { + if (forLikeStatement.initializer.kind === 225) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -53690,33 +54316,33 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229: + case 230: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226: + case 227: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232: + case 233: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231: + case 232: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 229: - case 226: + case 230: + case 227: return textSpan(node); - case 204: + case 205: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 256: + case 257: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232: + case 233: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -53748,7 +54374,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 || + if (node.parent.kind === 210 || node.parent.kind === 179 || node.parent.kind === 180) { return spanInPreviousNode(node); @@ -53761,17 +54387,17 @@ var ts; function spanInCloseParenToken(node) { switch (node.parent.kind) { case 184: - case 225: + case 226: case 185: case 149: case 148: case 151: case 152: case 150: - case 210: - case 209: case 211: - case 213: + case 210: + case 212: + case 214: case 179: case 180: case 183: @@ -53782,7 +54408,7 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 || + node.parent.kind === 258 || node.parent.kind === 144) { return spanInPreviousNode(node); } @@ -53795,13 +54421,13 @@ var ts; return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 210) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213) { + if (node.parent.kind === 214) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -53845,7 +54471,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -54152,10 +54778,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -54199,7 +54825,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 && + return declaration.kind === 231 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -54256,7 +54882,7 @@ var ts; ts.Debug.assert(classifications.spans.length % 3 === 0); var dense = classifications.spans; var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -54340,16 +54966,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 281: + case 282: processJSDocParameterTag(tag); break; - case 284: + case 285: processJSDocTemplateTag(tag); break; - case 283: + case 284: processElement(tag.typeExpression); break; - case 282: + case 283: processElement(tag.typeExpression); break; } @@ -54430,22 +55056,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248: + case 249: if (token.parent.tagName === token) { return 19; } break; - case 249: + case 250: if (token.parent.tagName === token) { return 20; } break; - case 247: + case 248: if (token.parent.tagName === token) { return 21; } break; - case 250: + case 251: if (token.parent.name === token) { return 22; } @@ -54465,10 +55091,10 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 223 || + if (token.parent.kind === 224 || token.parent.kind === 147 || token.parent.kind === 144 || - token.parent.kind === 250) { + token.parent.kind === 251) { return 5; } } @@ -54485,7 +55111,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 250 ? 24 : 6; + return token.parent.kind === 251 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -54499,7 +55125,7 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 226: + case 227: if (token.parent.name === token) { return 11; } @@ -54509,17 +55135,17 @@ var ts; return 15; } return; - case 227: + case 228: if (token.parent.name === token) { return 13; } return; - case 229: + case 230: if (token.parent.name === token) { return 12; } return; - case 230: + case 231: if (token.parent.name === token) { return 14; } @@ -54540,9 +55166,8 @@ var ts; } if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { processElement(child); } @@ -54579,7 +55204,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 249) { + location.parent && location.parent.kind === 250) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -54601,13 +55226,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_45 in nameTable) { - if (nameTable[name_45] === position) { + for (var name_46 in nameTable) { + if (nameTable[name_46] === position) { continue; } - if (!uniqueNames[name_45]) { - uniqueNames[name_45] = name_45; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); + if (!uniqueNames[name_46]) { + uniqueNames[name_46] = name_46; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -54657,7 +55282,7 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 257 && + if (node.parent.kind === 258 && node.parent.parent.kind === 176 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); @@ -54665,7 +55290,7 @@ var ts; else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 235 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 236 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { @@ -54725,6 +55350,9 @@ var ts; return undefined; } function addStringLiteralCompletionsFromType(type, result) { + if (type && type.flags & 16384) { + type = typeChecker.getApparentType(type); + } if (!type) { return; } @@ -55029,11 +55657,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_13; + currentDir = parent_14; } else { break; @@ -55165,9 +55793,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283: - case 281: + case 284: case 282: + case 283: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -55202,13 +55830,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_14.kind === 177) { + if (parent_15.kind === 177) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141) { + else if (parent_15.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -55221,7 +55849,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 && contextToken.parent.kind === 249) { + else if (kind === 40 && contextToken.parent.kind === 250) { isStartingCloseTag = true; location = contextToken; } @@ -55312,7 +55940,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247) || (jsxContainer.kind === 248)) { + if ((jsxContainer.kind === 248) || (jsxContainer.kind === 249)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -55333,9 +55961,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 || + scopeNode.kind === 262 || scopeNode.kind === 194 || - scopeNode.kind === 252 || + scopeNode.kind === 253 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -55363,11 +55991,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 248) { + if (contextToken.parent.kind === 249) { return true; } - if (contextToken.parent.kind === 249 || contextToken.parent.kind === 247) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246; + if (contextToken.parent.kind === 250 || contextToken.parent.kind === 248) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 247; } } return false; @@ -55397,16 +56025,16 @@ var ts; case 128: return true; case 22: - return containingNodeKind === 230; + return containingNodeKind === 231; case 16: - return containingNodeKind === 226; + return containingNodeKind === 227; case 57: - return containingNodeKind === 223 + return containingNodeKind === 224 || containingNodeKind === 192; case 13: return containingNodeKind === 194; case 14: - return containingNodeKind === 202; + return containingNodeKind === 203; case 113: case 111: case 112: @@ -55482,9 +56110,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 ? - 235 : - 241; + var declarationKind = namedImportsOrExports.kind === 239 ? + 236 : + 242; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -55505,9 +56133,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 || parent_15.kind === 172)) { - return parent_15; + var parent_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { + return parent_16; } break; } @@ -55520,8 +56148,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 238: - case 242: + case 239: + case 243: return contextToken.parent; } } @@ -55530,34 +56158,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent_17 = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 250: case 251: - if (parent_16 && (parent_16.kind === 247 || parent_16.kind === 248)) { - return parent_16; + case 252: + if (parent_17 && (parent_17.kind === 248 || parent_17.kind === 249)) { + return parent_17; } - else if (parent_16.kind === 250) { - return parent_16.parent; + else if (parent_17.kind === 251) { + return parent_17.parent; } break; case 9: - if (parent_16 && ((parent_16.kind === 250) || (parent_16.kind === 251))) { - return parent_16.parent; + if (parent_17 && ((parent_17.kind === 251) || (parent_17.kind === 252))) { + return parent_17.parent; } break; case 17: - if (parent_16 && - parent_16.kind === 252 && - parent_16.parent && - (parent_16.parent.kind === 250)) { - return parent_16.parent.parent; + if (parent_17 && + parent_17.kind === 253 && + parent_17.parent && + (parent_17.parent.kind === 251)) { + return parent_17.parent.parent; } - if (parent_16 && parent_16.kind === 251) { - return parent_16.parent; + if (parent_17 && parent_17.kind === 252) { + return parent_17.parent; } break; } @@ -55568,7 +56196,7 @@ var ts; switch (kind) { case 184: case 185: - case 225: + case 226: case 149: case 148: case 151: @@ -55584,16 +56212,16 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 223 || - containingNodeKind === 224 || - containingNodeKind === 205 || - containingNodeKind === 229 || + return containingNodeKind === 224 || + containingNodeKind === 225 || + containingNodeKind === 206 || + containingNodeKind === 230 || isFunction(containingNodeKind) || - containingNodeKind === 226 || - containingNodeKind === 197 || containingNodeKind === 227 || + containingNodeKind === 197 || + containingNodeKind === 228 || containingNodeKind === 173 || - containingNodeKind === 228; + containingNodeKind === 229; case 22: return containingNodeKind === 173; case 55: @@ -55601,22 +56229,22 @@ var ts; case 20: return containingNodeKind === 173; case 18: - return containingNodeKind === 256 || + return containingNodeKind === 257 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 229 || - containingNodeKind === 227 || + return containingNodeKind === 230 || + containingNodeKind === 228 || containingNodeKind === 161; case 24: return containingNodeKind === 146 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 || + (contextToken.parent.parent.kind === 228 || contextToken.parent.parent.kind === 161); case 26: - return containingNodeKind === 226 || + return containingNodeKind === 227 || containingNodeKind === 197 || - containingNodeKind === 227 || containingNodeKind === 228 || + containingNodeKind === 229 || isFunction(containingNodeKind); case 114: return containingNodeKind === 147; @@ -55629,9 +56257,9 @@ var ts; case 112: return containingNodeKind === 144; case 117: - return containingNodeKind === 239 || - containingNodeKind === 243 || - containingNodeKind === 237; + return containingNodeKind === 240 || + containingNodeKind === 244 || + containingNodeKind === 238; case 74: case 82: case 108: @@ -55680,8 +56308,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_46 = element.propertyName || element.name; - existingImportsOrExports[name_46.text] = true; + var name_47 = element.propertyName || element.name; + existingImportsOrExports[name_47.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -55695,8 +56323,8 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 257 && - m.kind !== 258 && + if (m.kind !== 258 && + m.kind !== 259 && m.kind !== 174 && m.kind !== 149 && m.kind !== 151 && @@ -55726,7 +56354,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250) { + if (attr.kind === 251) { seenNames[attr.name.text] = true; } } @@ -55875,58 +56503,58 @@ var ts; switch (node.kind) { case 89: case 81: - if (hasKind(node.parent, 208)) { + if (hasKind(node.parent, 209)) { return getIfElseOccurrences(node.parent); } break; case 95: - if (hasKind(node.parent, 216)) { + if (hasKind(node.parent, 217)) { return getReturnOccurrences(node.parent); } break; case 99: - if (hasKind(node.parent, 220)) { + if (hasKind(node.parent, 221)) { return getThrowOccurrences(node.parent); } break; case 73: - if (hasKind(parent(parent(node)), 221)) { + if (hasKind(parent(parent(node)), 222)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101: case 86: - if (hasKind(parent(node), 221)) { + if (hasKind(parent(node), 222)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97: - if (hasKind(node.parent, 218)) { + if (hasKind(node.parent, 219)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72: case 78: - if (hasKind(parent(parent(parent(node))), 218)) { + if (hasKind(parent(parent(parent(node))), 219)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71: case 76: - if (hasKind(node.parent, 215) || hasKind(node.parent, 214)) { + if (hasKind(node.parent, 216) || hasKind(node.parent, 215)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87: - if (hasKind(node.parent, 211) || - hasKind(node.parent, 212) || - hasKind(node.parent, 213)) { + if (hasKind(node.parent, 212) || + hasKind(node.parent, 213) || + hasKind(node.parent, 214)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105: case 80: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { + if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -55943,7 +56571,7 @@ var ts; break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 206)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -55955,10 +56583,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 220) { + if (node.kind === 221) { statementAccumulator.push(node); } - else if (node.kind === 221) { + else if (node.kind === 222) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -55978,17 +56606,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261) { - return parent_17; + var parent_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262) { + return parent_18; } - if (parent_17.kind === 221) { - var tryStatement = parent_17; + if (parent_18.kind === 222) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_17; + child = parent_18; } return undefined; } @@ -55997,7 +56625,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 || node.kind === 214) { + if (node.kind === 216 || node.kind === 215) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -56010,23 +56638,23 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 218: - if (statement.kind === 214) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 219: + if (statement.kind === 215) { continue; } - case 211: case 212: case 213: + case 214: + case 211: case 210: - case 209: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -56037,24 +56665,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 226 || + if (!(container.kind === 227 || container.kind === 197 || (declaration.kind === 144 && hasKind(container, 150)))) { return undefined; } } else if (modifier === 114) { - if (!(container.kind === 226 || container.kind === 197)) { + if (!(container.kind === 227 || container.kind === 197)) { return undefined; } } else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 231 || container.kind === 261)) { + if (!(container.kind === 232 || container.kind === 262)) { return undefined; } } else if (modifier === 116) { - if (!(container.kind === 226 || declaration.kind === 226)) { + if (!(container.kind === 227 || declaration.kind === 227)) { return undefined; } } @@ -56065,8 +56693,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 231: - case 261: + case 232: + case 262: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -56077,7 +56705,7 @@ var ts; case 150: nodes = container.parameters.concat(container.parent.members); break; - case 226: + case 227: case 197: nodes = container.members; if (modifierFlag & 28) { @@ -56158,7 +56786,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 209) { + if (loopNode.kind === 210) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105)) { @@ -56179,13 +56807,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return getLoopBreakContinueOccurrences(owner); - case 218: + case 219: return getSwitchCaseDefaultOccurrences(owner); } } @@ -56235,7 +56863,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 204))) { + if (!(func && hasKind(func.body, 205))) { return undefined; } var keywords = []; @@ -56249,7 +56877,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 208) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 209) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -56260,7 +56888,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 208)) { + if (!hasKind(ifStatement.elseStatement, 209)) { break; } ifStatement = ifStatement.elseStatement; @@ -56295,7 +56923,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 220; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -56499,16 +57127,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 236); + var defaultImport = ts.getDeclarationOfKind(symbol, 237); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 || - declaration.kind === 243) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 || + declaration.kind === 244) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 239 ? + return importOrExportSpecifier.kind === 240 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -56552,7 +57180,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226); + return ts.getAncestor(privateDeclaration, 227); } } if (symbol.flags & 8388608) { @@ -56576,7 +57204,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 261 && !ts.isExternalModule(container)) { + if (container.kind === 262 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -56813,7 +57441,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70) { - if (refNode.parent.kind === 258) { + if (refNode.parent.kind === 259) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -56823,24 +57451,24 @@ var ts; } var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); + var parent_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 205) { + ts.forEachReturnStatement(parent_19.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); + else if (isImplementationExpression(parent_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -56876,7 +57504,7 @@ var ts; function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { if (node.kind === 199 - && node.parent.kind === 255 + && node.parent.kind === 256 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -56923,7 +57551,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 227) { + else if (declaration.kind === 228) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -56997,11 +57625,11 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; - case 261: + case 262: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 225: + case 226: case 184: break; default: @@ -57009,7 +57637,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 261) { + if (searchSpaceNode.kind === 262) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -57044,7 +57672,7 @@ var ts; var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { case 184: - case 225: + case 226: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } @@ -57056,13 +57684,13 @@ var ts; } break; case 197: - case 226: + case 227: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 261: - if (container.kind === 261 && !ts.isExternalModule(container)) { + case 262: + if (container.kind === 262 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -57097,13 +57725,13 @@ var ts; for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { var position = possiblePositions_1[_i]; cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9) { + var node_3 = ts.getTouchingWord(sourceFile, position); + if (!node_3 || node_3.kind !== 9) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + references.push(getReferenceEntryFromNode(node_3)); } } } @@ -57111,7 +57739,7 @@ var ts; function populateSearchSymbolSet(symbol, location) { var result = [symbol]; var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -57161,7 +57789,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 227) { + else if (declaration.kind === 228) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -57293,7 +57921,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223) { + else if (node.kind === 224) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -57303,18 +57931,18 @@ var ts; } else { switch (node.kind) { - case 226: + case 227: case 197: - case 229: case 230: + case 231: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205) { - ts.Debug.assert(node.parent.kind === 224); + if (node.parent && node.parent.parent && node.parent.parent.kind === 206) { + ts.Debug.assert(node.parent.kind === 225); return node.parent.parent; } } @@ -57384,8 +58012,8 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 257: case 258: + case 259: case 149: case 151: case 152: @@ -57447,11 +58075,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 239 && declaration.parent && declaration.parent.kind === 238))) { + (declaration.kind === 240 && declaration.parent && declaration.parent.kind === 239))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 258) { + if (node.parent.kind === 259) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -57529,7 +58157,7 @@ var ts; var definition; ts.forEach(signatureDeclarations, function (d) { if ((selectConstructors && d.kind === 150) || - (!selectConstructors && (d.kind === 225 || d.kind === 149 || d.kind === 148))) { + (!selectConstructors && (d.kind === 226 || d.kind === 149 || d.kind === 148))) { declarations.push(d); if (d.body) definition = d; @@ -57605,7 +58233,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 258) { + if (node.parent.kind === 259) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -57697,7 +58325,7 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -57731,16 +58359,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225: + case 226: case 149: case 150: - case 226: - case 205: + case 227: + case 206: break findOwner; - case 261: + case 262: return undefined; - case 230: - if (commentOwner.parent.kind === 230) { + case 231: + if (commentOwner.parent.kind === 231) { return undefined; } break findOwner; @@ -57755,7 +58383,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 ? currentName.text : @@ -57780,7 +58408,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205) { + if (commentOwner.kind === 206) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -57823,10 +58451,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + for (var name_48 in nameToDeclarations) { + var declarations = nameToDeclarations[name_48]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); if (!matches) { continue; } @@ -57837,21 +58465,21 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name_48); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 || decl.kind === 239 || decl.kind === 234) { + if (decl.kind === 237 || decl.kind === 240 || decl.kind === 235) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -58076,14 +58704,14 @@ var ts; addLeafNode(node); } break; - case 236: + case 237: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { addLeafNode(namedBindings); } else { @@ -58095,11 +58723,11 @@ var ts; } break; case 174: - case 223: + case 224: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name_49 = decl.name; + if (ts.isBindingPattern(name_49)) { + addChildrenRecursively(name_49); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -58109,11 +58737,11 @@ var ts; } break; case 185: - case 225: + case 226: case 184: addNodeWithRecursiveChild(node, node.body); break; - case 229: + case 230: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -58123,9 +58751,9 @@ var ts; } endNode(); break; - case 226: - case 197: case 227: + case 197: + case 228: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -58133,21 +58761,21 @@ var ts; } endNode(); break; - case 230: + case 231: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243: - case 234: + case 244: + case 235: case 155: case 153: case 154: - case 228: + case 229: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285) { + if (tag.kind === 286) { addLeafNode(tag); } }); @@ -58195,12 +58823,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 231 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230) { + if (a.body.kind !== 231) { return true; } return areSameModule(a.body, b.body); @@ -58251,7 +58879,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return getModuleName(node); } var decl = node; @@ -58263,14 +58891,14 @@ var ts; case 185: case 197: return getFunctionOrClassName(node); - case 285: + case 286: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return getModuleName(node); } var name = node.name; @@ -58281,15 +58909,15 @@ var ts; } } switch (node.kind) { - case 261: + case 262: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; case 185: - case 225: - case 184: case 226: + case 184: + case 227: case 197: if (ts.getModifierFlags(node) & 512) { return "default"; @@ -58303,7 +58931,7 @@ var ts; return "()"; case 155: return "[]"; - case 285: + case 286: return getJSDocTypedefTagName(node); default: return ""; @@ -58315,7 +58943,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -58343,23 +58971,23 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226: - case 197: - case 229: case 227: + case 197: case 230: - case 261: case 228: - case 285: + case 231: + case 262: + case 229: + case 286: return true; case 150: case 149: case 151: case 152: - case 223: + case 224: return hasSomeImportantChild(item); case 185: - case 225: + case 226: case 184: return isTopLevelFunctionDeclaration(item); default: @@ -58370,8 +58998,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231: - case 261: + case 232: + case 262: case 149: case 150: return true; @@ -58382,7 +59010,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 && childKind !== 174; + return childKind !== 224 && childKind !== 174; }); } } @@ -58437,20 +59065,20 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 230) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 231) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 230 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 231 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { return !member.name || member.name.kind === 142; } function getNodeSpan(node) { - return node.kind === 261 + return node.kind === 262 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -58458,14 +59086,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 224) { return ts.declarationNameToString(node.parent.name); } else if (node.parent.kind === 192 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 && node.parent.name) { + else if (node.parent.kind === 258 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -58561,26 +59189,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204: + case 205: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent_20 = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_19.kind === 209 || - parent_19.kind === 212 || - parent_19.kind === 213 || - parent_19.kind === 211 || - parent_19.kind === 208 || - parent_19.kind === 210 || - parent_19.kind === 217 || - parent_19.kind === 256) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent_20.kind === 210 || + parent_20.kind === 213 || + parent_20.kind === 214 || + parent_20.kind === 212 || + parent_20.kind === 209 || + parent_20.kind === 211 || + parent_20.kind === 218 || + parent_20.kind === 257) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221) { - var tryStatement = parent_19; + if (parent_20.kind === 222) { + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -58600,17 +59228,17 @@ var ts; }); break; } - case 231: { + case 232: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226: case 227: - case 229: + case 228: + case 230: case 176: - case 232: { + case 233: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); @@ -58878,7 +59506,8 @@ var ts; return str === str.toLowerCase(); } function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -58886,7 +59515,7 @@ var ts; return -1; } function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -58954,7 +59583,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -59527,7 +60156,7 @@ var ts; var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 && node.parent.parent.parent.kind === 181) { + else if (node.parent.kind === 203 && node.parent.parent.parent.kind === 181) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; @@ -59604,7 +60233,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261; n = n.parent) { + for (var n = node; n.kind !== 262; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -59966,7 +60595,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230); + var declaration = ts.getDeclarationOfKind(symbol, 231); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); @@ -60001,7 +60630,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 228) { + else if (declaration.kind === 229) { addInPrefix(); displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); @@ -60014,7 +60643,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260) { + if (declaration.kind === 261) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -60026,7 +60655,7 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233) { + if (symbol.declarations[0].kind === 234) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128)); @@ -60037,7 +60666,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234) { + if (declaration.kind === 235) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -60105,7 +60734,7 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 192) { @@ -60191,11 +60820,11 @@ var ts; if (declaration.kind === 184) { return true; } - if (declaration.kind !== 223 && declaration.kind !== 225) { + if (declaration.kind !== 224 && declaration.kind !== 226) { return false; } - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { - if (parent_20.kind === 261 || parent_20.kind === 231) { + for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { + if (parent_21.kind === 262 || parent_21.kind === 232) { return false; } } @@ -60386,10 +61015,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 251: + case 249: case 250: case 248: - case 249: - case 247: return node.kind === 70; } } @@ -60722,10 +61351,10 @@ var ts; this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 140, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([19, 21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60736,10 +61365,10 @@ var ts; this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); @@ -60759,6 +61388,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109, 75]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60767,9 +61397,10 @@ var ts; this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 133, 114, 136, 138]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 133, 114, 136, 138, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -60797,6 +61428,7 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -60825,7 +61457,7 @@ var ts; this.NoSpaceBetweenTagAndTemplateString, this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -60840,6 +61472,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; this.LowPriorityCommonRules = [ this.NoSpaceBeforeSemicolon, @@ -60848,7 +61481,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); @@ -60889,15 +61521,15 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name_50 in o) { + if (o[name_50] === rule) { + return name_50; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 211; + return context.contextNode.kind === 212; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); @@ -60907,24 +61539,25 @@ var ts; case 192: case 193: case 200: - case 243: - case 239: + case 244: + case 240: case 156: case 164: case 165: return true; case 174: - case 228: - case 234: - case 223: + case 229: + case 235: + case 224: case 144: - case 260: + case 261: case 147: case 146: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 212: - return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; case 213: + case 143: + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 214: return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; } return false; @@ -60938,6 +61571,9 @@ var ts; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 172 || Rules.IsSingleLineBlockContext(context); + }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); }; @@ -60958,17 +61594,17 @@ var ts; return true; } switch (node.kind) { - case 204: - case 232: + case 205: + case 233: case 176: - case 231: + case 232: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225: + case 226: case 149: case 148: case 151: @@ -60977,58 +61613,64 @@ var ts; case 184: case 150: case 185: - case 227: + case 228: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 || context.contextNode.kind === 184; + return context.contextNode.kind === 226 || context.contextNode.kind === 184; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226: - case 197: case 227: - case 229: - case 161: + case 197: + case 228: case 230: - case 241: + case 161: + case 231: case 242: - case 235: - case 238: + case 243: + case 236: + case 239: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226: - case 230: - case 229: - case 204: - case 256: + case 227: case 231: - case 218: + case 230: + case 257: + case 232: + case 219: return true; + case 205: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 185 && + blockParent.kind !== 184) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208: - case 218: - case 211: + case 209: + case 219: case 212: case 213: + case 214: + case 211: + case 222: case 210: - case 221: - case 209: - case 217: - case 256: + case 218: + case 257: return true; default: return false; @@ -61059,19 +61701,19 @@ var ts; return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246; + return context.contextNode.kind !== 247; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252; + return context.contextNode.kind === 253; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250; + return context.nextTokenParent.kind === 251; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250; + return context.contextNode.kind === 251; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247; + return context.contextNode.kind === 248; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -61089,14 +61731,14 @@ var ts; return node.kind === 145; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 && + return context.currentTokenParent.kind === 225 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230; + return context.contextNode.kind === 231; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 161; @@ -61108,10 +61750,11 @@ var ts; switch (parent.kind) { case 157: case 182: - case 226: - case 197: + case 229: case 227: - case 225: + case 197: + case 228: + case 226: case 184: case 185: case 149: @@ -61139,6 +61782,9 @@ var ts; Rules.IsYieldOrYieldStarWithOperand = function (context) { return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 201; + }; return Rules; }()); formatting.Rules = Rules; @@ -61423,6 +62069,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -61501,6 +62153,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -61598,17 +62256,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 226: case 227: + case 228: return ts.rangeContainsRange(parent.members, node); - case 230: - var body = parent.body; - return body && body.kind === 231 && ts.rangeContainsRange(body.statements, node); - case 261: - case 204: case 231: + var body = parent.body; + return body && body.kind === 232 && ts.rangeContainsRange(body.statements, node); + case 262: + case 205: + case 232: return ts.rangeContainsRange(parent.statements, node); - case 256: + case 257: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -61764,10 +62422,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226: return 74; - case 227: return 108; - case 225: return 88; - case 229: return 229; + case 227: return 74; + case 228: return 108; + case 226: return 88; + case 230: return 230; case 151: return 124; case 152: return 133; case 149: @@ -61799,17 +62457,30 @@ var ts; switch (kind) { case 16: case 17: - case 20: - case 21: case 18: case 19: case 81: case 105: case 56: return indentation; - default: - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40: + case 28: { + if (container.kind === 249 || + container.kind === 250 || + container.kind === 248) { + return indentation; + } + break; + } + case 20: + case 21: { + if (container.kind !== 170) { + return indentation; + } + break; + } } + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -61850,7 +62521,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -61880,7 +62551,7 @@ var ts; if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -61915,10 +62586,10 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -61931,7 +62602,7 @@ var ts; if (formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -62121,7 +62792,7 @@ var ts; startLine++; } var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -62212,7 +62883,7 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 150: - case 225: + case 226: case 184: case 149: case 148: @@ -62436,7 +63107,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 261 || !parentAndChildShareLine); + (parent.kind === 262 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -62460,7 +63131,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 && parent.elseStatement === child) { + if (parent.kind === 209 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -62482,7 +63153,7 @@ var ts; return node.parent.properties; case 175: return node.parent.elements; - case 225: + case 226: case 184: case 185: case 149: @@ -62604,35 +63275,36 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207: - case 226: - case 197: + case 208: case 227: - case 229: + case 197: case 228: + case 230: + case 229: case 175: - case 204: - case 231: + case 205: + case 232: case 176: case 161: + case 170: case 163: - case 232: + case 233: + case 255: case 254: - case 253: case 183: case 177: case 179: case 180: - case 205: - case 223: - case 240: - case 216: + case 206: + case 224: + case 241: + case 217: case 193: case 173: case 172: + case 249: case 248: - case 247: - case 252: + case 253: case 148: case 153: case 154: @@ -62642,10 +63314,10 @@ var ts; case 166: case 181: case 189: - case 242: - case 238: case 243: case 239: + case 244: + case 240: return true; } return false; @@ -62653,27 +63325,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 209: case 210: - case 212: - case 213: case 211: - case 208: - case 225: + case 213: + case 214: + case 212: + case 209: + case 226: case 184: case 149: case 185: case 150: case 151: case 152: - return childKind !== 204; - case 241: - return childKind !== 242; - case 235: - return childKind !== 236 || - (child.namedBindings && child.namedBindings.kind !== 238); - case 246: - return childKind !== 249; + return childKind !== 205; + case 242: + return childKind !== 243; + case 236: + return childKind !== 237 || + (child.namedBindings && child.namedBindings.kind !== 239); + case 247: + return childKind !== 250; } return indentByDefault; } @@ -62723,24 +63395,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_7 = writer.string(); + ts.releaseStringWriter(writer); + return result_7; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8) && !!(flags & 128); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -62762,7 +63530,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -62778,7 +63546,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 && ts.isSuperCall(n.expression)) { + if (n.kind === 208 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -62791,6 +63559,216 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind === 20) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70: + switch (token.parent.kind) { + case 224: + switch (token.parent.parent.parent.kind) { + case 212: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 214: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 225) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 213: + return undefined; + case 257: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + case 235: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 240: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + case 237: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 238: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 238: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 236 && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + 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); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -62876,7 +63854,10 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -62887,6 +63868,11 @@ var ts; var symbolIdActionMap = new ImportCodeActionMap(); var cachedImportDeclarations = ts.createMap(); var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, false, true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -62894,7 +63880,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -62931,10 +63916,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } - if (node.kind === 234) { + if (node.kind === 235) { return node; } node = node.parent; @@ -62952,7 +63937,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { return getCodeActionsForExistingImport(existingDeclarations); @@ -62967,9 +63952,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { var declaration = declarations_11[_i]; - if (declaration.kind === 235) { + if (declaration.kind === 236) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237) { + if (namedBindings && namedBindings.kind === 238) { namespaceImportDeclaration = declaration; } else { @@ -62985,7 +63970,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); @@ -62996,7 +63981,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245) { + if (declaration.moduleReference && declaration.moduleReference.kind === 246) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -63029,7 +64014,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235) { + if (declaration.kind === 236) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -63055,7 +64040,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; var newText = cachedNewImportInsertPosition === sourceFile.getStart() ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter : "" + context.newLineCharacter + importStatementText + ";"; @@ -63072,7 +64059,7 @@ var ts; tryGetModuleNameAsNodeModule() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261) { + if (moduleSymbol.valueDeclaration.kind !== 262) { return moduleSymbol.name; } } @@ -63085,6 +64072,7 @@ var ts; if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -63104,7 +64092,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -63223,144 +64211,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - if (token.kind === 20) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70: - switch (token.parent.kind) { - case 223: - switch (token.parent.parent.parent.kind) { - case 211: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212: - return undefined; - case 256: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - case 234: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - case 236: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 && importDecl.parent) { - importDecl = importDecl.parent; + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 151: + case 152: + case 146: + case 147: + var typeString = checker.typeToString(type, enclosingDeclaration, 0); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 148: + case 149: + var signatures = checker.getSignaturesOfType(type, 0); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(153); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(144); + newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4) { + return "public "; + } + else if (flags & 16) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; @@ -63425,7 +64389,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292, nodes.pos, nodes.end, this); + var list = createNode(293, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -63448,7 +64412,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 && this.kind <= 291; + var useJSDocScanner_1 = this.kind >= 279 && this.kind <= 292; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -63721,9 +64685,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_7 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_7 !== undefined) { - return result_7; + var result_8 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_8 !== undefined) { + return result_8; } if (declaration.name.kind === 142) { var expr = declaration.name.expression; @@ -63747,7 +64711,7 @@ var ts; } function visit(node) { switch (node.kind) { - case 225: + case 226: case 184: case 149: case 148: @@ -63767,18 +64731,18 @@ var ts; } ts.forEachChild(node, visit); break; - case 226: - case 197: case 227: + case 197: case 228: case 229: case 230: - case 234: - case 243: - case 239: - case 234: - case 236: + case 231: + case 235: + case 244: + case 240: + case 235: case 237: + case 238: case 151: case 152: case 161: @@ -63789,7 +64753,7 @@ var ts; if (!ts.hasModifier(node, 92)) { break; } - case 223: + case 224: case 174: { var decl = node; if (ts.isBindingPattern(decl.name)) { @@ -63799,24 +64763,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260: + case 261: case 147: case 146: addDeclaration(node); break; - case 241: + case 242: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 235: + case 236: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { addDeclaration(importClause.namedBindings); } else { @@ -64411,7 +65375,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 230 && + if (nodeForStartPos.parent.parent.kind === 231 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -64600,7 +65564,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -64709,7 +65673,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 245 || + node.parent.kind === 246 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -65075,15 +66039,15 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_50 = names_2[_i]; - var resolution = newResolutions[name_50]; + var name_51 = names_2[_i]; + var resolution = newResolutions[name_51]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_50]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_51]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_50] = resolution = loader(name_50, containingFile, compilerOptions, this); + newResolutions[name_51] = resolution = loader(name_51, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -65123,6 +66087,9 @@ var ts; return resolution.failedLookupLocations.length === 0; } }; + LSHost.prototype.getNewLine = function () { + return this.host.newLine; + }; LSHost.prototype.getProjectVersion = function () { return this.project.getProjectVersion(); }; @@ -65328,7 +66295,7 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 230 || statement.name.kind !== 9) { + if (statement.kind !== 231 || statement.name.kind !== 9) { return false; } } @@ -65439,7 +66406,7 @@ var ts; var ModuleBuilderFileInfo = (function (_super) { __extends(ModuleBuilderFileInfo, _super); function ModuleBuilderFileInfo() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.references = []; _this.referencedBy = []; return _this; @@ -65802,7 +66769,7 @@ var ts; info.detachFromProject(this); } } - else { + if (!this.program || !this.languageServiceEnabled) { for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { var root = _c[_b]; root.detachFromProject(this); @@ -65948,9 +66915,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_51 in file.resolvedModules) { - if (!file.resolvedModules[name_51] && !ts.isExternalModuleNameRelative(name_51)) { - var trimmed = name_51.trim(); + for (var name_52 in file.resolvedModules) { + if (!file.resolvedModules[name_52] && !ts.isExternalModuleNameRelative(name_52)) { + var trimmed = name_52.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -68539,9 +69506,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_53 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -69022,7 +69989,7 @@ var ts; if (len > 1) { var insertedNodes = new Array(len - 1); var startNode = leafNode; - for (var i = 1, len_1 = lines.length; i < len_1; i++) { + for (var i = 1; i < lines.length; i++) { insertedNodes[i - 1] = new LineLeaf(lines[i]); } var pathIndex = this.startPath.length - 2; @@ -69219,8 +70186,8 @@ var ts; var snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { var snapIndex = snap.index; - for (var i = 0, len = this.changes.length; i < len; i++) { - var change = this.changes[i]; + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var change = _a[_i]; snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); } snap = new LineIndexSnapshot(this.currentVersion + 1, this); @@ -69241,8 +70208,8 @@ var ts; var textChangeRanges = []; for (var i = oldVersion + 1; i <= newVersion; i++) { var snap = this.versions[this.versionToIndex(i)]; - for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; + for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { + var textChange = _a[_i]; textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); } } @@ -69342,7 +70309,7 @@ var ts; LineIndex.prototype.load = function (lines) { if (lines.length > 0) { var leaves = []; - for (var i = 0, len = lines.length; i < len; i++) { + for (var i = 0; i < lines.length; i++) { leaves[i] = new LineLeaf(lines[i]); } this.root = LineIndex.buildTreeFromBottom(leaves); @@ -69502,8 +70469,8 @@ var ts; LineNode.prototype.updateCounts = function () { this.totalChars = 0; this.totalLines = 0; - for (var i = 0, len = this.children.length; i < len; i++) { - var child = this.children[i]; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; this.totalChars += child.charCount(); this.totalLines += child.lineCount(); } @@ -70044,7 +71011,7 @@ var ts; var IOSession = (function (_super) { __extends(IOSession, _super); function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, telemetryEnabled, logger) { - var _this; + var _this = this; var typingsInstaller = disableAutomaticTypingAcquisition ? undefined : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine); @@ -70074,7 +71041,8 @@ var ts; function parseLoggingEnvironmentString(logEnvStr) { var logEnv = { logToFile: true }; var args = logEnvStr.split(" "); - for (var i = 0, len = args.length; i < (len - 1); i += 2) { + var len = args.length - 1; + for (var i = 0; i < len; i += 2) { var option = args[i]; var value = args[i + 1]; if (option && value) { @@ -70928,7 +71896,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index e01f4393032..25ed333b299 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -764,12 +764,14 @@ declare namespace ts.server.protocol { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } @@ -1094,102 +1096,102 @@ declare namespace ts { ExpressionWithTypeArguments = 199, AsExpression = 200, NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, + MetaProperty = 202, + TemplateSpan = 203, + SemicolonClassElement = 204, + Block = 205, + VariableStatement = 206, + EmptyStatement = 207, + ExpressionStatement = 208, + IfStatement = 209, + DoStatement = 210, + WhileStatement = 211, + ForStatement = 212, + ForInStatement = 213, + ForOfStatement = 214, + ContinueStatement = 215, + BreakStatement = 216, + ReturnStatement = 217, + WithStatement = 218, + SwitchStatement = 219, + LabeledStatement = 220, + ThrowStatement = 221, + TryStatement = 222, + DebuggerStatement = 223, + VariableDeclaration = 224, + VariableDeclarationList = 225, + FunctionDeclaration = 226, + ClassDeclaration = 227, + InterfaceDeclaration = 228, + TypeAliasDeclaration = 229, + EnumDeclaration = 230, + ModuleDeclaration = 231, + ModuleBlock = 232, + CaseBlock = 233, + NamespaceExportDeclaration = 234, + ImportEqualsDeclaration = 235, + ImportDeclaration = 236, + ImportClause = 237, + NamespaceImport = 238, + NamedImports = 239, + ImportSpecifier = 240, + ExportAssignment = 241, + ExportDeclaration = 242, + NamedExports = 243, + ExportSpecifier = 244, + MissingDeclaration = 245, + ExternalModuleReference = 246, + JsxElement = 247, + JsxSelfClosingElement = 248, + JsxOpeningElement = 249, + JsxClosingElement = 250, + JsxAttribute = 251, + JsxSpreadAttribute = 252, + JsxExpression = 253, + CaseClause = 254, + DefaultClause = 255, + HeritageClause = 256, + CatchClause = 257, + PropertyAssignment = 258, + ShorthandPropertyAssignment = 259, + SpreadAssignment = 260, + EnumMember = 261, + SourceFile = 262, + JSDocTypeExpression = 263, + JSDocAllType = 264, + JSDocUnknownType = 265, + JSDocArrayType = 266, + JSDocUnionType = 267, + JSDocTupleType = 268, + JSDocNullableType = 269, + JSDocNonNullableType = 270, + JSDocRecordType = 271, + JSDocRecordMember = 272, + JSDocTypeReference = 273, + JSDocOptionalType = 274, + JSDocFunctionType = 275, + JSDocVariadicType = 276, + JSDocConstructorType = 277, + JSDocThisType = 278, + JSDocComment = 279, + JSDocTag = 280, + JSDocAugmentsTag = 281, + JSDocParameterTag = 282, + JSDocReturnTag = 283, + JSDocTypeTag = 284, + JSDocTemplateTag = 285, + JSDocTypedefTag = 286, + JSDocPropertyTag = 287, + JSDocTypeLiteral = 288, + JSDocLiteralType = 289, + JSDocNullKeyword = 290, + JSDocUndefinedKeyword = 291, + JSDocNeverKeyword = 292, + SyntaxList = 293, + NotEmittedStatement = 294, + PartiallyEmittedExpression = 295, + MergeDeclarationMarker = 296, + EndOfDeclarationMarker = 297, Count = 298, FirstAssignment = 57, LastAssignment = 69, @@ -1216,10 +1218,10 @@ declare namespace ts { FirstBinaryOperator = 26, LastBinaryOperator = 69, FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstJSDocNode = 263, + LastJSDocNode = 289, + FirstJSDocTagNode = 279, + LastJSDocTagNode = 292, } const enum NodeFlags { None = 0, @@ -1846,6 +1848,11 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; @@ -1880,6 +1887,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1895,10 +1903,6 @@ declare namespace ts { interface EndOfDeclarationMarker extends Statement { kind: SyntaxKind.EndOfDeclarationMarker; } - interface RawExpression extends PrimaryExpression { - kind: SyntaxKind.RawExpression; - text: string; - } interface MergeDeclarationMarker extends Statement { kind: SyntaxKind.MergeDeclarationMarker; } @@ -1912,7 +1916,7 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; @@ -2458,6 +2462,7 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): ObjectType[]; @@ -2470,6 +2475,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -2492,6 +2499,7 @@ declare namespace ts { isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; + getApparentType(type: Type): Type; tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol; getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(): Diagnostic[]; @@ -2505,6 +2513,7 @@ declare namespace ts { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -2542,6 +2551,7 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, } const enum SymbolFormatFlags { None = 0, @@ -2751,6 +2761,7 @@ declare namespace ts { TypeChecked = 1, LexicalThis = 2, CaptureThis = 4, + CaptureNewTarget = 8, SuperInstance = 256, SuperStatic = 512, ContextChecked = 1024, @@ -3671,6 +3682,9 @@ declare namespace ts { function memoize(callback: () => T): () => T; function chain(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U; function compose(...args: ((t: T) => T)[]): (t: T) => T; + function formatStringFromArgs(text: string, args: { + [index: number]: string; + }, baseIndex?: number): string; let localizedDiagnosticMessages: Map; function getLocaleSpecificMessage(message: DiagnosticMessage): string; function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; @@ -4178,7 +4192,7 @@ declare namespace ts { key: string; message: string; }; - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: number; category: DiagnosticCategory; key: string; @@ -5120,6 +5134,12 @@ declare namespace ts { key: string; message: string; }; + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Duplicate_identifier_0: { code: number; category: DiagnosticCategory; @@ -6494,6 +6514,18 @@ declare namespace ts { key: string; message: string; }; + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; JSX_element_attributes_type_0_may_not_be_a_union_type: { code: number; category: DiagnosticCategory; @@ -6548,6 +6580,12 @@ declare namespace ts { key: string; message: string; }; + JSX_spread_child_must_be_an_array_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Cannot_emit_namespaced_JSX_elements_in_React: { code: number; category: DiagnosticCategory; @@ -6854,6 +6892,18 @@ declare namespace ts { key: string; message: string; }; + The_operand_of_a_delete_operator_must_be_a_property_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Import_declaration_0_is_using_private_name_1: { code: number; category: DiagnosticCategory; @@ -7862,6 +7912,12 @@ declare namespace ts { key: string; message: string; }; + File_0_has_an_unsupported_extension_so_skipping_it: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Only_amd_and_system_modules_are_supported_alongside_0: { code: number; category: DiagnosticCategory; @@ -7940,7 +7996,7 @@ declare namespace ts { key: string; message: string; }; - Loading_module_as_file_Slash_folder_candidate_module_location_0: { + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: number; category: DiagnosticCategory; key: string; @@ -7958,7 +8014,7 @@ declare namespace ts { key: string; message: string; }; - Loading_module_0_from_node_modules_folder: { + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: number; category: DiagnosticCategory; key: string; @@ -8252,6 +8308,18 @@ declare namespace ts { key: string; message: string; }; + Resolution_for_module_0_was_found_in_cache: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Directory_0_does_not_exist_skipping_all_lookups_in_it: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Variable_0_implicitly_has_an_1_type: { code: number; category: DiagnosticCategory; @@ -8588,6 +8656,18 @@ declare namespace ts { key: string; message: string; }; + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Circularity_detected_while_resolving_configuration_Colon_0: { code: number; category: DiagnosticCategory; @@ -8636,13 +8716,7 @@ declare namespace ts { key: string; message: string; }; - Implement_interface_on_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_on_class: { + Implement_interface_0: { code: number; category: DiagnosticCategory; key: string; @@ -8684,6 +8758,18 @@ declare namespace ts { key: string; message: string; }; + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; }; } declare namespace ts { @@ -8904,12 +8990,23 @@ declare namespace ts { }): string[] | undefined; function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; + } + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + } + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; + } + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; function directoryProbablyExists(directoryName: string, host: { directoryExists?: (directoryName: string) => boolean; }): boolean; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; function loadModuleFromGlobalCache(moduleName: string, projectName: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { @@ -8988,6 +9085,8 @@ declare namespace ts { let fullTripleSlashReferenceTypeReferenceDirectiveRegEx: RegExp; let fullTripleSlashAMDReferencePathRegEx: RegExp; function isPartOfTypeNode(node: Node): boolean; + function isChildOfNodeWithKind(node: Node, kind: SyntaxKind): boolean; + function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression; function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void; function getRestParameterElementType(node: TypeNode): TypeNode; @@ -8998,6 +9097,7 @@ declare namespace ts { function isFunctionLikeKind(kind: SyntaxKind): boolean; function introducesArgumentsExoticObject(node: Node): boolean; function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement; + function unwrapInnermostStatmentOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void): Statement; function isFunctionBlock(node: Node): boolean; function isObjectLiteralMethod(node: Node): node is MethodDeclaration; function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration; @@ -9006,6 +9106,7 @@ declare namespace ts { function getContainingFunction(node: Node): FunctionLikeDeclaration; function getContainingClass(node: Node): ClassLikeDeclaration; function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; + function getNewTargetContainer(node: Node): Node; function getSuperContainer(node: Node, stopOnFunctions: boolean): Node; function getImmediatelyInvokedFunctionExpression(func: Node): CallExpression; function isSuperProperty(node: Node): node is SuperProperty; @@ -9050,6 +9151,7 @@ declare namespace ts { } function getAssignmentTargetKind(node: Node): AssignmentKind; function isAssignmentTarget(node: Node): boolean; + function isDeleteTarget(node: Node): boolean; function isNodeDescendantOf(node: Node, ancestor: Node): boolean; function isInAmbientContext(node: Node): boolean; function isDeclarationName(name: Node): boolean; @@ -9062,7 +9164,7 @@ declare namespace ts { function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile; - function getAncestor(node: Node, kind: SyntaxKind): Node; + function getAncestor(node: Node | undefined, kind: SyntaxKind): Node; function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult; function isKeyword(token: SyntaxKind): boolean; function isTrivia(token: SyntaxKind): boolean; @@ -9094,7 +9196,7 @@ declare namespace ts { function getExpressionAssociativity(expression: Expression): Associativity; function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; function getExpressionPrecedence(expression: Expression): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.RawExpression | SyntaxKind.Count; + function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.MetaProperty | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.Count; function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; function createDiagnosticCollection(): DiagnosticCollection; function escapeString(s: string): string; @@ -9210,6 +9312,7 @@ declare namespace ts { function isTemplateHead(node: Node): node is TemplateHead; function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; function isIdentifier(node: Node): node is Identifier; + function isVoidExpression(node: Node): node is VoidExpression; function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier; function isModifier(node: Node): node is Modifier; function isQualifiedName(node: Node): node is QualifiedName; @@ -9488,7 +9591,7 @@ declare namespace ts { function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function createJsxSpreadAttribute(expression: Expression, location?: TextRange): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; - function createJsxExpression(expression: Expression, location?: TextRange): JsxExpression; + function createJsxExpression(expression: Expression, dotDotDotToken: Token, location?: TextRange): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[], location?: TextRange): HeritageClause; function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; @@ -9510,7 +9613,6 @@ declare namespace ts { function createMergeDeclarationMarker(original: Node): MergeDeclarationMarker; function createPartiallyEmittedExpression(expression: Expression, original?: Node, location?: TextRange): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createRawExpression(text: string): RawExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression, location?: TextRange): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression, location?: TextRange): DestructuringAssignment; @@ -9539,6 +9641,7 @@ declare namespace ts { function createLetDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; function createConstDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; function getHelperName(name: string): Identifier; + function restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement; interface CallBinding { target: LeftHandSideExpression; thisArg: Expression; @@ -10043,6 +10146,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -10051,6 +10155,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -10058,6 +10163,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -10066,6 +10172,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } @@ -10416,6 +10523,7 @@ declare namespace ts { configJsonObject: any; diagnostics: Diagnostic[]; }; + function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile): number; } declare namespace ts.BreakpointResolver { function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number): TextSpan; @@ -10695,6 +10803,7 @@ declare namespace ts.formatting { SpaceAfterLetConstInVariableDeclaration: Rule; NoSpaceBeforeOpenParenInFuncCall: Rule; SpaceAfterFunctionInFuncDecl: Rule; + SpaceBeforeOpenParenInFuncDecl: Rule; NoSpaceBeforeOpenParenInFuncDecl: Rule; SpaceAfterVoidOperator: Rule; NoSpaceBetweenReturnAndSemicolon: Rule; @@ -10703,6 +10812,7 @@ declare namespace ts.formatting { SpaceAfterGetSetInMember: Rule; SpaceBeforeBinaryKeywordOperator: Rule; SpaceAfterBinaryKeywordOperator: Rule; + SpaceAfterConstructor: Rule; NoSpaceAfterConstructor: Rule; NoSpaceAfterModuleImport: Rule; SpaceAfterCertainTypeScriptKeywords: Rule; @@ -10776,6 +10886,7 @@ declare namespace ts.formatting { NoSpaceAfterEqualInJsxAttribute: Rule; NoSpaceAfterTypeAssertion: Rule; SpaceAfterTypeAssertion: Rule; + NoSpaceBeforeNonNullAssertionOperator: Rule; constructor(); static IsForContext(context: FormattingContext): boolean; static IsNotForContext(context: FormattingContext): boolean; @@ -10783,6 +10894,7 @@ declare namespace ts.formatting { static IsNotBinaryOpContext(context: FormattingContext): boolean; static IsConditionalOperatorContext(context: FormattingContext): boolean; static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; + static IsBraceWrappedContext(context: FormattingContext): boolean; static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; static IsMultilineBlockContext(context: FormattingContext): boolean; static IsSingleLineBlockContext(context: FormattingContext): boolean; @@ -10820,6 +10932,7 @@ declare namespace ts.formatting { static IsTypeAssertionContext(context: FormattingContext): boolean; static IsVoidOpContext(context: FormattingContext): boolean; static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; + static IsNonNullAssertionContext(context: FormattingContext): boolean; } } declare namespace ts.formatting { @@ -10981,6 +11094,17 @@ declare namespace ts.codefix { } declare namespace ts.codefix { } +declare namespace ts.codefix { +} +declare namespace ts.codefix { +} +declare namespace ts.codefix { +} +declare namespace ts.codefix { +} +declare namespace ts.codefix { + function getMissingMembersInsertion(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker, newlineChar: string): string; +} declare namespace ts { const servicesVersion = "0.5"; interface DisplayPartsSymbolWriter extends SymbolWriter { @@ -11082,6 +11206,7 @@ declare namespace ts.server { startRecordingFilesWithChangedResolutions(): void; finishRecordingFilesWithChangedResolutions(): Path[]; private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, getResultFileName, logChanges); + getNewLine(): string; getProjectVersion(): string; getCompilationSettings(): CompilerOptions; useCaseSensitiveFileNames(): boolean; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 842c5458a89..459706962fb 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 ts; (function (ts) { var OperationCanceledException = (function () { @@ -206,7 +211,7 @@ var ts; ts.toPath = toPath; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +230,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +240,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -245,7 +250,7 @@ var ts; } ts.find = find; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +273,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +283,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -981,6 +986,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2475,7 +2481,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -2632,6 +2638,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2861,6 +2868,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2870,6 +2879,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2921,6 +2931,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -3089,6 +3101,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,10 +3115,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -3154,6 +3167,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3210,22 +3225,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3606,7 +3624,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +3810,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -5539,6 +5557,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -6156,6 +6175,7 @@ var ts; newLineCharacter: host.newLine || "\n", convertTabsToSpaces: true, indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, insertSpaceAfterCommaDelimiter: true, insertSpaceAfterSemicolonInForStatements: true, insertSpaceBeforeAndAfterBinaryOperators: true, @@ -6163,8 +6183,10 @@ var ts; insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, }; @@ -6293,6 +6315,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -6300,9 +6328,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -6314,13 +6339,13 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2: - case 0: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -6382,6 +6407,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -6436,7 +6462,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -6452,7 +6482,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -6493,31 +6524,115 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_1 = ts.getDirectoryPath(current); + if (parent_1 === current || directoryPathMap.contains(parent_1)) { + break; + } + directoryPathMap.set(parent_1, result); + current = parent_1; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -6642,33 +6757,33 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -6685,10 +6800,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6716,11 +6854,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -6729,19 +6867,21 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -6750,16 +6890,22 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -6769,73 +6915,117 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -6847,10 +7037,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -6981,7 +7174,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { + while (node && node.kind !== 262) { node = node.parent; } return node; @@ -6989,11 +7182,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: return true; } return false; @@ -7058,18 +7251,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 292 && node._children.length > 0) { + if (node.kind === 293 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; + return node.kind >= 263 && node.kind <= 289; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; + return node.kind >= 279 && node.kind <= 292; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -7163,11 +7356,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; + return node.kind === 224 && node.parent.kind === 257; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 && + return node && node.kind === 231 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -7176,11 +7369,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); + return node.kind === 231 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || + return node.kind === 262 || + node.kind === 231 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7193,9 +7386,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261: + case 262: return ts.isExternalModule(node.parent); - case 231: + case 232: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7207,22 +7400,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261: - case 232: - case 256: - case 230: - case 211: + case 262: + case 233: + case 257: + case 231: case 212: case 213: + case 214: case 150: case 149: case 151: case 152: - case 225: + case 226: case 184: case 185: return true; - case 204: + case 205: return parentNode && !isFunctionLike(parentNode); } return false; @@ -7300,7 +7493,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { + if (node.body && node.body.kind === 205) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7312,26 +7505,26 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261: + case 262: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 223: + case 224: case 174: - case 226: - case 197: case 227: + case 197: + case 228: + case 231: case 230: - case 229: - case 260: - case 225: + case 261: + case 226: case 184: case 149: case 151: case 152: - case 228: + case 229: errorNode = node.name; break; case 185: @@ -7355,7 +7548,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); + return node.kind === 230 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7372,7 +7565,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 + return node.kind === 208 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -7429,24 +7622,24 @@ var ts; case 141: case 177: case 98: - var parent_1 = node.parent; - if (parent_1.kind === 160) { + var parent_2 = node.parent; + if (parent_2.kind === 160) { return false; } - if (156 <= parent_1.kind && parent_1.kind <= 171) { + if (156 <= parent_2.kind && parent_2.kind <= 171) { return true; } - switch (parent_1.kind) { + switch (parent_2.kind) { case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); case 143: - return node === parent_1.constraint; + return node === parent_2.constraint; case 147: case 146: case 144: - case 223: - return node === parent_1.type; - case 225: + case 224: + return node === parent_2.type; + case 226: case 184: case 185: case 150: @@ -7454,16 +7647,16 @@ var ts; case 148: case 151: case 152: - return node === parent_1.type; + return node === parent_2.type; case 153: case 154: case 155: - return node === parent_1.type; + return node === parent_2.type; case 182: - return node === parent_1.type; + return node === parent_2.type; case 179: case 180: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 181: return false; } @@ -7471,27 +7664,41 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216: + case 217: return visitor(node); - case 232: - case 204: - case 208: + case 233: + case 205: case 209: case 210: case 211: case 212: case 213: - case 217: + case 214: case 218: - case 253: - case 254: case 219: - case 221: - case 256: + case 254: + case 255: + case 220: + case 222: + case 257: return ts.forEachChild(node, traverse); } } @@ -7507,11 +7714,11 @@ var ts; if (operand) { traverse(operand); } - case 229: - case 227: case 230: case 228: - case 226: + case 231: + case 229: + case 227: case 197: return; default: @@ -7545,13 +7752,13 @@ var ts; if (node) { switch (node.kind) { case 174: - case 260: + case 261: case 144: - case 257: + case 258: case 147: case 146: - case 258: - case 223: + case 259: + case 224: return true; } } @@ -7563,7 +7770,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); + return node && (node.kind === 227 || node.kind === 197); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7574,7 +7781,7 @@ var ts; switch (kind) { case 150: case 184: - case 225: + case 226: case 185: case 149: case 148: @@ -7597,7 +7804,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: return true; } @@ -7606,20 +7813,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return true; - case 219: + case 220: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); + return node && node.kind === 205 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -7683,9 +7902,9 @@ var ts; if (!includeArrowFunctions) { continue; } - case 225: + case 226: case 184: - case 230: + case 231: case 147: case 146: case 149: @@ -7696,13 +7915,26 @@ var ts; case 153: case 154: case 155: - case 229: - case 261: + case 230: + case 262: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 150: + case 226: + case 184: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -7713,7 +7945,7 @@ var ts; case 142: node = node.parent; break; - case 225: + case 226: case 184: case 185: if (!stopOnFunctions) { @@ -7742,13 +7974,13 @@ var ts; function getImmediatelyInvokedFunctionExpression(func) { if (func.kind === 184 || func.kind === 185) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent_3 = func.parent; + while (parent_3.kind === 183) { + prev = parent_3; + parent_3 = parent_3.parent; } - if (parent_2.kind === 179 && parent_2.expression === prev) { - return parent_2; + if (parent_3.kind === 179 && parent_3.expression === prev) { + return parent_3; } } } @@ -7762,7 +7994,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157: - case 272: + case 273: return node.typeName; case 199: return isEntityNameExpression(node.expression) @@ -7796,21 +8028,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226: + case 227: return true; case 147: - return node.parent.kind === 226; + return node.parent.kind === 227; case 151: case 152: case 149: return node.body !== undefined - && node.parent.kind === 226; + && node.parent.kind === 227; case 144: return node.parent.body !== undefined && (node.parent.kind === 150 || node.parent.kind === 149 || node.parent.kind === 152) - && node.parent.parent.kind === 226; + && node.parent.parent.kind === 227; } return false; } @@ -7826,7 +8058,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226: + case 227: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149: case 152: @@ -7836,9 +8068,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { + if (parent.kind === 249 || + parent.kind === 248 || + parent.kind === 250) { return parent.tagName === node; } return false; @@ -7877,10 +8109,11 @@ var ts; case 194: case 12: case 198: - case 246: case 247: + case 248: case 195: case 189: + case 202: return true; case 141: while (node.parent.kind === 141) { @@ -7894,53 +8127,53 @@ var ts; case 8: case 9: case 98: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223: + var parent_4 = node.parent; + switch (parent_4.kind) { + case 224: case 144: case 147: case 146: - case 260: - case 257: + case 261: + case 258: case 174: - return parent_3.initializer === node; - case 207: + return parent_4.initializer === node; case 208: case 209: case 210: - case 216: + case 211: case 217: case 218: - case 253: - case 220: - case 218: - return parent_3.expression === node; - case 211: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + case 219: + case 254: + case 221: + case 219: + return parent_4.expression === node; + case 212: + var forStatement = parent_4; + return (forStatement.initializer === node && forStatement.initializer.kind !== 225) || forStatement.condition === node || forStatement.incrementor === node; - case 212: case 213: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + case 214: + var forInStatement = parent_4; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225) || forInStatement.expression === node; case 182: case 200: - return node === parent_3.expression; - case 202: - return node === parent_3.expression; + return node === parent_4.expression; + case 203: + return node === parent_4.expression; case 142: - return node === parent_3.expression; + return node === parent_4.expression; case 145: + case 253: case 252: - case 251: - case 259: + case 260: return true; case 199: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent_4)) { return true; } } @@ -7955,7 +8188,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; + return node.kind === 235 && node.moduleReference.kind === 246; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7964,7 +8197,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; + return node.kind === 235 && node.moduleReference.kind !== 246; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7988,7 +8221,7 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184; } @@ -8035,35 +8268,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235) { + if (node.kind === 236) { return node.moduleSpecifier; } - if (node.kind === 234) { + if (node.kind === 235) { var reference = node.moduleReference; - if (reference.kind === 245) { + if (reference.kind === 246) { return reference.expression; } } - if (node.kind === 241) { + if (node.kind === 242) { return node.moduleSpecifier; } - if (node.kind === 230 && node.name.kind === 9) { + if (node.kind === 231 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 + return node.kind === 236 && node.importClause && !!node.importClause.name; } @@ -8074,8 +8307,8 @@ var ts; case 144: case 149: case 148: + case 259: case 258: - case 257: case 147: case 146: return node.questionToken !== undefined; @@ -8085,9 +8318,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 && + return node.kind === 275 && node.parameters.length > 0 && - node.parameters[0].type.kind === 276; + node.parameters[0].type.kind === 277; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -8100,7 +8333,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281) { + if (doc.kind === 282) { if (doc.kind === kind) { result.push(doc); } @@ -8126,9 +8359,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205; + parent.parent.parent.kind === 206; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; + parent.parent.kind === 206; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -8138,13 +8371,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 && parent.operatorToken.kind === 57 && - parent.parent.kind === 207; + parent.parent.kind === 208; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; + var isModuleDeclaration = node.kind === 231 && + parent && parent.kind === 231; + var isPropertyAssignmentExpression = parent && parent.kind === 258; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -8162,17 +8395,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281); + var tags = getJSDocTags(func, 282); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { var name_8 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_8; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_8; }); } else { return undefined; @@ -8180,7 +8413,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); + var tag = getFirstJSDocTag(node, 284); if (!tag && node.kind === 144) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -8191,15 +8424,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); + return getFirstJSDocTag(node, 281); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); + return getFirstJSDocTag(node, 283); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -8212,8 +8445,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { + if (node.type && node.type.kind === 276 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276; })) { return true; } } @@ -8237,19 +8470,19 @@ var ts; case 191: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: case 213: + case 214: return parent.initializer === node ? 1 : 0; case 183: case 175: case 196: node = parent; break; - case 258: + case 259: if (parent.name !== node) { return 0; } - case 257: + case 258: node = parent.parent; break; default: @@ -8263,6 +8496,17 @@ var ts; return getAssignmentTargetKind(node) !== 0; } ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 177 && node.kind !== 178) { + return false; + } + node = node.parent; + while (node && node.kind === 183) { + node = node.parent; + } + return node && node.kind === 186; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -8274,7 +8518,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 262 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8287,7 +8531,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { + if (parent.kind === 240 || parent.kind === 244) { if (parent.propertyName) { return true; } @@ -8313,8 +8557,8 @@ var ts; case 148: case 151: case 152: - case 260: - case 257: + case 261: + case 258: case 177: return parent.name === node; case 141: @@ -8326,22 +8570,22 @@ var ts; } return false; case 174: - case 239: + case 240: return parent.propertyName === node; - case 243: + case 244: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || - node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); + return node.kind === 235 || + node.kind === 234 || + node.kind === 237 && !!node.name || + node.kind === 238 || + node.kind === 240 || + node.kind === 244 || + node.kind === 241 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8521,13 +8765,13 @@ var ts; var kind = node.kind; return kind === 150 || kind === 184 - || kind === 225 + || kind === 226 || kind === 185 || kind === 149 || kind === 151 || kind === 152 - || kind === 230 - || kind === 261; + || kind === 231 + || kind === 262; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8649,14 +8893,13 @@ var ts; case 184: case 185: case 197: - case 246: case 247: + case 248: case 11: case 12: case 194: case 183: case 198: - case 297: return 19; case 181: case 177: @@ -8830,13 +9073,12 @@ var ts; "\u0085": "\\u0085" }); function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -9712,8 +9954,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229: case 230: + case 231: return parseNode === parseNode.parent.name; } } @@ -9731,7 +9973,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { + if (declaration.kind === 227 && declaration !== node) { return true; } } @@ -9782,6 +10024,10 @@ var ts; return node.kind === 70; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { return isIdentifier(node) && node.autoGenerateKind > 0; } @@ -9849,18 +10095,18 @@ var ts; || kind === 151 || kind === 152 || kind === 155 - || kind === 203; + || kind === 204; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 - || kind === 258 + return kind === 258 || kind === 259 + || kind === 260 || kind === 149 || kind === 151 || kind === 152 - || kind === 244; + || kind === 245; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { @@ -9913,7 +10159,7 @@ var ts; ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223: + case 224: case 144: case 174: return true; @@ -9991,8 +10237,8 @@ var ts; || kind === 178 || kind === 180 || kind === 179 - || kind === 246 || kind === 247 + || kind === 248 || kind === 181 || kind === 175 || kind === 183 @@ -10011,7 +10257,7 @@ var ts; || kind === 100 || kind === 96 || kind === 201 - || kind === 297; + || kind === 202; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10039,7 +10285,6 @@ var ts; || kind === 196 || kind === 200 || kind === 198 - || kind === 297 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10053,11 +10298,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294; + return node.kind === 295; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293; + return node.kind === 294; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10070,11 +10315,11 @@ var ts; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 202; + return node.kind === 203; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 204; + return node.kind === 205; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10092,121 +10337,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223; + return node.kind === 224; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224; + return node.kind === 225; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232; + return node.kind === 233; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 - || kind === 230; + return kind === 232 + || kind === 231; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 - || kind === 237; + return kind === 239 + || kind === 238; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239; + return node.kind === 240; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242; + return node.kind === 243; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243; + return node.kind === 244; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 231 || node.kind === 230; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 || kind === 174 - || kind === 226 + || kind === 227 || kind === 197 || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 + || kind === 230 + || kind === 261 + || kind === 244 + || kind === 226 || kind === 184 || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 + || kind === 237 + || kind === 235 + || kind === 240 + || kind === 228 || kind === 149 || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 + || kind === 231 + || kind === 234 + || kind === 238 || kind === 144 - || kind === 257 + || kind === 258 || kind === 147 || kind === 146 || kind === 152 - || kind === 258 - || kind === 228 + || kind === 259 + || kind === 229 || kind === 143 - || kind === 223 - || kind === 285; + || kind === 224 + || kind === 286; } function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 + return kind === 226 + || kind === 245 || kind === 227 || kind === 228 || kind === 229 || kind === 230 + || kind === 231 + || kind === 236 || kind === 235 - || kind === 234 + || kind === 242 || kind === 241 - || kind === 240 - || kind === 233; + || kind === 234; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 - || kind === 216 - || kind === 218 - || kind === 220 - || kind === 221 - || kind === 205 + return kind === 216 + || kind === 215 + || kind === 223 || kind === 210 + || kind === 208 + || kind === 207 + || kind === 213 + || kind === 214 + || kind === 212 + || kind === 209 + || kind === 220 || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; + || kind === 219 + || kind === 221 + || kind === 222 + || kind === 206 + || kind === 211 + || kind === 218 + || kind === 294 + || kind === 297 + || kind === 296; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10224,22 +10469,22 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204; + || kind === 205; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 245 + return kind === 246 || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 248; + return node.kind === 249; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249; + return node.kind === 250; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -10251,60 +10496,60 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 + return kind === 247 + || kind === 253 + || kind === 248 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 - || kind === 251; + return kind === 251 + || kind === 252; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 252; + || kind === 253; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 - || kind === 254; + return kind === 254 + || kind === 255; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255; + return node.kind === 256; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256; + return node.kind === 257; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 257; + return node.kind === 258; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 261; + return node.kind === 262; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10445,7 +10690,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228) { return current; } } @@ -10465,14 +10710,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= ts.getModifierFlags(node); } return flags; @@ -10481,14 +10726,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223) { + if (node.kind === 224) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 225) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 206) { flags |= node.flags; } return flags; @@ -10547,7 +10792,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 + var ConstructorForKind = kind === 262 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -11243,7 +11488,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + var node = createNode(203, location); node.expression = expression; node.literal = literal; return node; @@ -11257,7 +11502,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + var block = createNode(205, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11273,7 +11518,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + var node = createNode(206, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11288,7 +11533,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + var node = createNode(225, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11301,7 +11546,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); + var node = createNode(224, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11316,11 +11561,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206, location); + return createNode(207, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); + var node = createNode(208, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11333,7 +11578,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11348,7 +11593,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209, location); + var node = createNode(210, location); node.statement = statement; node.expression = expression; return node; @@ -11362,7 +11607,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210, location); + var node = createNode(211, location); node.expression = expression; node.statement = statement; return node; @@ -11376,7 +11621,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + var node = createNode(212, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11392,7 +11637,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11407,7 +11652,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11422,7 +11667,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -11437,7 +11682,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215, location); + var node = createNode(216, location); if (label) { node.label = label; } @@ -11452,7 +11697,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.expression = expression; return node; } @@ -11465,7 +11710,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217, location); + var node = createNode(218, location); node.expression = expression; node.statement = statement; return node; @@ -11479,7 +11724,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); + var node = createNode(219, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11493,7 +11738,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219, location); + var node = createNode(220, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11507,7 +11752,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220, location); + var node = createNode(221, location); node.expression = expression; return node; } @@ -11520,7 +11765,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11535,7 +11780,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.clauses = createNodeArray(clauses); return node; } @@ -11548,7 +11793,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); + var node = createNode(226, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11568,7 +11813,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); + var node = createNode(227, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11586,7 +11831,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11602,7 +11847,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11616,7 +11861,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.name = name; return node; } @@ -11629,7 +11874,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.elements = createNodeArray(elements); return node; } @@ -11642,7 +11887,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + var node = createNode(240, location); node.propertyName = propertyName; node.name = name; return node; @@ -11656,7 +11901,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11672,7 +11917,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11688,7 +11933,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.elements = createNodeArray(elements); return node; } @@ -11701,7 +11946,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11715,7 +11960,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + var node = createNode(247, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11730,7 +11975,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11744,7 +11989,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + var node = createNode(249, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11758,7 +12003,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + var node = createNode(250, location); node.tagName = tagName; return node; } @@ -11771,7 +12016,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + var node = createNode(251, location); node.name = name; node.initializer = initializer; return node; @@ -11785,7 +12030,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -11797,21 +12042,22 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(255, location); + var node = createNode(256, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11825,7 +12071,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253, location); + var node = createNode(254, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11839,7 +12085,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254, location); + var node = createNode(255, location); node.statements = createNodeArray(statements); return node; } @@ -11852,7 +12098,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + var node = createNode(257, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11866,7 +12112,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); + var node = createNode(258, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11881,14 +12127,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); + var node = createNode(259, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259, location); + var node = createNode(260, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -11909,7 +12155,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createNode(262, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11969,27 +12215,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createNode(294, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createNode(297); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createNode(296); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + var node = createNode(295, location || original); node.expression = expression; node.original = original; return node; @@ -12002,12 +12248,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; function createComma(left, right) { return createBinary(left, 25, right); } @@ -12171,6 +12411,19 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12270,9 +12523,9 @@ var ts; case 151: case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); case 258: + return createExpressionForPropertyAssignment(property, receiver); + case 259: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149: return createExpressionForMethodDeclaration(property, receiver); @@ -12630,7 +12883,7 @@ var ts; case 177: node = node.expression; continue; - case 294: + case 295: node = node.expression; continue; } @@ -12678,7 +12931,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { + while (node.kind === 295) { node = node.expression; } return node; @@ -12738,7 +12991,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 262) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12929,10 +13182,10 @@ var ts; var name_11 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { + if (node.kind === 236 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { + if (node.kind === 242 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12996,11 +13249,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 258: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 259: + return bindingElement.name; + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -13020,7 +13273,7 @@ var ts; case 174: return bindingElement.dotDotDotToken; case 196: - case 259: + case 260: return bindingElement; } return undefined; @@ -13036,7 +13289,7 @@ var ts; : propertyName; } break; - case 257: + case 258: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13044,7 +13297,7 @@ var ts; : propertyName; } break; - case 259: + case 260: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -13149,15 +13402,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 236: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 235: + if (node.moduleReference.kind === 246) { externalImports.push(node); } break; - case 241: + case 242: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13184,12 +13437,12 @@ var ts; } } break; - case 240: + case 241: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 206: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13197,7 +13450,7 @@ var ts; } } break; - case 225: + case 226: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13215,7 +13468,7 @@ var ts; } } break; - case 226: + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13263,7 +13516,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 262) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { @@ -13312,20 +13565,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259: + case 260: return visitNode(cbNode, node.expression); case 144: case 147: case 146: - case 257: - case 223: + case 258: + case 224: case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13351,7 +13604,7 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13443,6 +13696,8 @@ var ts; visitNode(cbNode, node.type); case 201: return visitNode(cbNode, node.expression); + case 202: + return visitNode(cbNode, node.name); case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -13451,84 +13706,77 @@ var ts; visitNode(cbNode, node.whenFalse); case 196: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 205: + case 232: return visitNodes(cbNodes, node.statements); - case 261: + case 262: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 206: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 225: return visitNodes(cbNodes, node.declarations); - case 207: - return visitNode(cbNode, node.expression); case 208: + return visitNode(cbNode, node.expression); + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 210: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 211: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 212: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + case 216: + return visitNode(cbNode, node.label); + case 217: + return visitNode(cbNode, node.expression); case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232: + case 233: return visitNodes(cbNodes, node.clauses); - case 253: + case 254: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254: + case 255: return visitNodes(cbNodes, node.statements); - case 219: + case 220: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220: - return visitNode(cbNode, node.expression); case 221: + return visitNode(cbNode, node.expression); + case 222: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 257: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145: return visitNode(cbNode, node.expression); - case 226: - case 197: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 227: + case 197: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13540,143 +13788,151 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 261: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 237: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: - return visitNode(cbNode, node.name); - case 237: + case 234: return visitNode(cbNode, node.name); case 238: - case 242: + return visitNode(cbNode, node.name); + case 239: + case 243: return visitNodes(cbNodes, node.elements); - case 241: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 240: + case 244: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 203: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142: return visitNode(cbNode, node.expression); - case 255: + case 256: return visitNodes(cbNodes, node.types); case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: - return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNode(cbNode, node.expression); + case 245: + return visitNodes(cbNodes, node.decorators); + case 247: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: case 248: + case 249: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250: + case 251: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251: - return visitNode(cbNode, node.expression); case 252: return visitNode(cbNode, node.expression); - case 249: + case 253: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250: return visitNode(cbNode, node.tagName); - case 262: + case 263: return visitNode(cbNode, node.type); - case 266: - return visitNodes(cbNodes, node.types); case 267: return visitNodes(cbNodes, node.types); - case 265: + case 268: + return visitNodes(cbNodes, node.types); + case 266: return visitNode(cbNode, node.elementType); + case 270: + return visitNode(cbNode, node.type); case 269: return visitNode(cbNode, node.type); - case 268: - return visitNode(cbNode, node.type); - case 270: + case 271: return visitNode(cbNode, node.literal); - case 272: + case 273: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273: - return visitNode(cbNode, node.type); case 274: + return visitNode(cbNode, node.type); + case 275: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); case 276: return visitNode(cbNode, node.type); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNode(cbNode, node.type); + case 272: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 279: return visitNodes(cbNodes, node.tags); - case 281: + case 282: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: - return visitNode(cbNode, node.typeExpression); case 283: return visitNode(cbNode, node.typeExpression); - case 280: - return visitNode(cbNode, node.typeExpression); case 284: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 281: + return visitNode(cbNode, node.typeExpression); case 285: + return visitNodes(cbNodes, node.typeParameters); + case 286: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 288: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 287: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 295: return visitNode(cbNode, node.expression); - case 288: + case 289: return visitNode(cbNode, node.literal); } } @@ -13840,7 +14096,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(262, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14459,7 +14715,7 @@ var ts; case 151: case 152: case 147: - case 203: + case 204: return true; case 149: var methodDeclaration = node; @@ -14473,8 +14729,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: case 254: + case 255: return true; } } @@ -14483,42 +14739,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: + case 226: + case 206: case 205: - case 204: + case 209: case 208: - case 207: - case 220: + case 221: + case 217: + case 219: case 216: - case 218: case 215: + case 213: case 214: case 212: - case 213: case 211: - case 210: - case 217: - case 206: - case 221: - case 219: - case 209: + case 218: + case 207: case 222: + case 220: + case 210: + case 223: + case 236: case 235: - case 234: + case 242: case 241: - case 240: - case 230: - case 226: + case 231: case 227: - case 229: case 228: + case 230: + case 229: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 261; } function isReusableTypeMember(node) { if (node) { @@ -14534,7 +14790,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 224) { return false; } var variableDeclarator = node; @@ -14666,7 +14922,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(203); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -15791,8 +16047,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 249) { + var node = createNode(247, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15802,7 +16058,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 248); result = opening; } if (inExpressionContext && token() === 26) { @@ -15862,7 +16118,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(249, fullStart); scanJsxText(); } else { @@ -15874,7 +16130,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(248, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15893,9 +16149,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(253); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -15912,7 +16169,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(251); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15927,7 +16184,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(252); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15935,7 +16192,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(250); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16152,7 +16409,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(260, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16171,7 +16428,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(259, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -16182,7 +16439,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(258, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16228,8 +16485,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(202, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -16238,7 +16502,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(205); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16269,12 +16533,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(207); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16284,7 +16548,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -16295,7 +16559,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(211); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16318,21 +16582,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(213, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + var forOfStatement = createNode(214, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(212, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -16350,7 +16614,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 216 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16358,7 +16622,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16367,7 +16631,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16376,7 +16640,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(254); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -16384,7 +16648,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(255); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -16394,12 +16658,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(233, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -16407,14 +16671,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(221); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -16425,7 +16689,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(257); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16435,7 +16699,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(223); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -16444,13 +16708,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(220, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(208, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16602,9 +16866,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); - case 71: return parseBreakOrContinueStatement(215); + case 71: + return parseBreakOrContinueStatement(216); case 95: return parseReturnStatement(); case 106: @@ -16683,7 +16947,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16755,7 +17019,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(224); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16764,7 +17028,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(225); switch (token()) { case 103: break; @@ -16793,7 +17057,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(206, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16801,7 +17065,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16986,7 +17250,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(204); nextToken(); return finishNode(result); } @@ -17020,7 +17284,7 @@ var ts; return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17055,7 +17319,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(256); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -17078,7 +17342,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -17089,7 +17353,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136); @@ -17101,13 +17365,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(261, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -17122,7 +17386,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(232, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -17133,7 +17397,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -17145,7 +17409,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139) { @@ -17190,7 +17454,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(234, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -17206,7 +17470,7 @@ var ts; if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + var importEqualsDeclaration = createNode(235, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17216,7 +17480,7 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(236, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || @@ -17230,13 +17494,13 @@ var ts; return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(237, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(239); } return finishNode(importClause); } @@ -17246,7 +17510,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(246); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -17264,7 +17528,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(238); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -17272,14 +17536,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 239 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(244); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(240); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17298,13 +17562,13 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 240 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { @@ -17312,7 +17576,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); + node.exportClause = parseNamedImportsOrExports(243); if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); @@ -17322,7 +17586,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(241, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -17401,10 +17665,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 + || node.kind === 235 && node.moduleReference.kind === 246 + || node.kind === 236 || node.kind === 241 + || node.kind === 242 ? node : undefined; }); @@ -17440,7 +17704,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(263, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -17451,12 +17715,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(267, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(274, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17467,20 +17731,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(266, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(269, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(270, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17532,27 +17796,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(278); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(276); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(275); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -17573,7 +17837,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(273); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -17613,18 +17877,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(271); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(270); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(268); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -17638,7 +17902,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(267); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -17654,12 +17918,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(264); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(289); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17672,11 +17936,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(265, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(269, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17820,7 +18084,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(279, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17930,7 +18194,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17985,7 +18249,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17996,20 +18260,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18024,7 +18288,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18033,7 +18297,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -18042,7 +18306,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(286, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -18056,7 +18320,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 273) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { var name_16 = jsDocTypeReference.name; @@ -18074,7 +18338,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18115,7 +18379,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(231, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18159,7 +18423,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); @@ -18182,7 +18446,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18474,7 +18738,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -18501,16 +18765,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 228 || node.kind === 229) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 236 || node.kind === 235) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 232) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18526,7 +18790,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 231) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -18635,7 +18899,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231)) { symbol.valueDeclaration = node; } } @@ -18666,9 +18930,9 @@ var ts; return "__new"; case 155: return "__index"; - case 241: + case 242: return "__export"; - case 240: + case 241: return node.isExportEquals ? "export=" : "default"; case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -18682,20 +18946,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: case 226: + case 227: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 275: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144: - ts.Debug.assert(node.parent.kind === 274); + ts.Debug.assert(node.parent.kind === 275); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 286: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -18739,7 +19003,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18759,7 +19023,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 244 || (node.kind === 235 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18767,7 +19031,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18828,7 +19092,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 262) { node.flags |= emitFlags; } if (isIIFE) { @@ -18904,43 +19168,43 @@ var ts; return; } switch (node.kind) { - case 210: + case 211: bindWhileStatement(node); break; - case 209: + case 210: bindDoStatement(node); break; - case 211: + case 212: bindForStatement(node); break; - case 212: case 213: + case 214: bindForInOrForOfStatement(node); break; - case 208: + case 209: bindIfStatement(node); break; - case 216: - case 220: + case 217: + case 221: bindReturnOrThrow(node); break; + case 216: case 215: - case 214: bindBreakOrContinueStatement(node); break; - case 221: + case 222: bindTryStatement(node); break; - case 218: + case 219: bindSwitchStatement(node); break; - case 232: + case 233: bindCaseBlock(node); break; - case 253: + case 254: bindCaseClause(node); break; - case 219: + case 220: bindLabeledStatement(node); break; case 190: @@ -18958,7 +19222,7 @@ var ts; case 193: bindConditionalExpressionFlow(node); break; - case 223: + case 224: bindVariableDeclarationFlow(node); break; case 179: @@ -19124,11 +19388,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: - case 210: case 209: - return parent.expression === node; case 211: + case 210: + return parent.expression === node; + case 212: case 193: return parent.condition === node; } @@ -19192,7 +19456,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 220 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19227,7 +19491,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 225) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19249,7 +19513,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 217) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19269,7 +19533,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19326,7 +19590,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19391,7 +19655,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 210) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } @@ -19422,13 +19686,13 @@ var ts; else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 258) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 259) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 260) { bindAssignmentTargetFlow(p.expression); } } @@ -19528,7 +19792,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 213 || node.parent.parent.kind === 214) { bindInitializedVariableFlow(node); } } @@ -19555,28 +19819,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197: - case 226: - case 229: + case 227: + case 230: case 176: case 161: - case 287: - case 270: + case 288: + case 271: return 1; - case 227: - return 1 | 64; - case 274: - case 230: case 228: + return 1 | 64; + case 275: + case 231: + case 229: case 170: return 1 | 32; - case 261: + case 262: return 1 | 4 | 32; case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } case 150: - case 225: + case 226: case 148: case 151: case 152: @@ -19589,17 +19853,17 @@ var ts; case 184: case 185: return 1 | 4 | 32 | 8 | 16; - case 231: + case 232: return 4; case 147: return node.initializer ? 4 : 0; - case 256: - case 211: + case 257: case 212: case 213: - case 232: + case 214: + case 233: return 2; - case 204: + case 205: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19615,20 +19879,20 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 231: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 262: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197: - case 226: + case 227: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 230: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161: case 176: - case 227: - case 270: - case 287: + case 228: + case 271: + case 288: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 158: case 159: @@ -19640,11 +19904,11 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 274: - case 228: + case 275: + case 229: case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } @@ -19660,11 +19924,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 262 ? node : node.body; + if (body && (body.kind === 262 || body.kind === 232)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 242 || stat.kind === 241) { return true; } } @@ -19740,11 +20004,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 260 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 258 || prop.kind === 259 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -19766,10 +20030,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 231: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 262: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19859,8 +20123,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 262 && + blockScopeContainer.kind !== 231 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19943,14 +20207,14 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 286) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -19982,7 +20246,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 257: return checkStrictModeCatchClause(node); case 186: return checkStrictModeDeleteExpression(node); @@ -19992,7 +20256,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 218: return checkStrictModeWithStatement(node); case 167: seenThisKeyword = true; @@ -20003,22 +20267,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: return bindParameter(node); - case 223: + case 224: case 174: return bindVariableDeclarationOrBindingElement(node); case 147: case 146: - case 271: + case 272: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 287: return bindJSDocProperty(node); - case 257: case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 260: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 259: - case 251: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 261: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 260: + case 252: var root = container; var hasRest = false; while (root.parent) { @@ -20039,7 +20303,7 @@ var ts; case 149: case 148: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: + case 226: return bindFunctionDeclaration(node); case 150: return declareSymbolAndAddToSymbolTable(node, 16384, 0); @@ -20049,12 +20313,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536, 74687); case 158: case 159: - case 274: + case 275: return bindFunctionOrConstructorType(node); case 161: case 170: - case 287: - case 270: + case 288: + case 271: return bindAnonymousDeclaration(node, 2048, "__type"); case 176: return bindObjectLiteralExpression(node); @@ -20067,43 +20331,43 @@ var ts; } break; case 197: - case 226: + case 227: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 228: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 286: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); case 229: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 230: + return bindEnumDeclaration(node); + case 231: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); - case 236: - return bindImportClause(node); - case 241: - return bindExportDeclaration(node); + case 235: + case 238: case 240: + case 244: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 234: + return bindNamespaceExportDeclaration(node); + case 237: + return bindImportClause(node); + case 242: + return bindExportDeclaration(node); + case 241: return bindExportAssignment(node); - case 261: + case 262: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 205: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 232: return updateStrictModeStatementList(node.statements); } } @@ -20131,7 +20395,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20141,17 +20405,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 262) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_5 = node.parent; + if (!ts.isExternalModule(parent_5)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20190,7 +20454,7 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 226 || container.kind === 184) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } @@ -20226,7 +20490,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 227) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -20336,15 +20600,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 207) || + node.kind === 227 || + (node.kind === 231 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 230 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 206 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20362,13 +20626,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180: return computeNewExpression(node, subtreeFlags); - case 230: + case 231: return computeModuleDeclaration(node, subtreeFlags); case 183: return computeParenthesizedExpression(node, subtreeFlags); case 192: return computeBinaryExpression(node, subtreeFlags); - case 207: + case 208: return computeExpressionStatement(node, subtreeFlags); case 144: return computeParameter(node, subtreeFlags); @@ -20376,23 +20640,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184: return computeFunctionExpression(node, subtreeFlags); - case 225: - return computeFunctionDeclaration(node, subtreeFlags); - case 223: - return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeFunctionDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclaration(node, subtreeFlags); + case 225: + return computeVariableDeclarationList(node, subtreeFlags); + case 206: + return computeVariableStatement(node, subtreeFlags); + case 220: + return computeLabeledStatement(node, subtreeFlags); + case 227: return computeClassDeclaration(node, subtreeFlags); case 197: return computeClassExpression(node, subtreeFlags); - case 255: - return computeHeritageClause(node, subtreeFlags); case 256: + return computeHeritageClause(node, subtreeFlags); + case 257: return computeCatchClause(node, subtreeFlags); case 199: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -20405,7 +20669,7 @@ var ts; case 151: case 152: return computeAccessor(node, subtreeFlags); - case 234: + case 235: return computeImportEquals(node, subtreeFlags); case 177: return computePropertyAccess(node, subtreeFlags); @@ -20793,25 +21057,25 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: + case 230: + case 261: case 182: case 200: case 201: case 130: transformFlags |= 3; break; - case 246: case 247: case 248: - case 10: case 249: + case 10: case 250: case 251: case 252: + case 253: transformFlags |= 4; break; - case 213: + case 214: transformFlags |= 8; case 12: case 13: @@ -20819,8 +21083,9 @@ var ts; case 15: case 194: case 181: - case 258: + case 259: case 114: + case 202: transformFlags |= 192; break; case 195: @@ -20850,8 +21115,8 @@ var ts; case 164: case 165: case 166: - case 227: case 228: + case 229: case 167: case 168: case 169: @@ -20869,7 +21134,7 @@ var ts; case 196: transformFlags |= 192 | 524288; break; - case 259: + case 260: transformFlags |= 8 | 1048576; break; case 96: @@ -20917,22 +21182,22 @@ var ts; transformFlags |= 192; } break; - case 209: case 210: case 211: case 212: + case 213: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 262: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 216: - case 214: + case 217: case 215: + case 216: transformFlags |= 33554432; break; } @@ -20948,18 +21213,18 @@ var ts; case 180: case 175: return 537396545; - case 230: + case 231: return 574674241; case 144: return 536872257; case 185: return 601249089; case 184: - case 225: - return 601281857; - case 224: - return 546309441; case 226: + return 601281857; + case 225: + return 546309441; + case 227: case 197: return 539358529; case 150: @@ -20981,12 +21246,12 @@ var ts; case 153: case 154: case 155: - case 227: case 228: + case 229: return -3; case 176: return 540087617; - case 256: + case 257: return 537920833; case 172: case 173: @@ -21056,9 +21321,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -21067,6 +21334,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -21089,7 +21357,8 @@ var ts; tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -21183,6 +21452,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var typeofEQFacts = ts.createMap({ @@ -21328,7 +21598,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 231 && source.valueDeclaration.kind !== 231))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21423,7 +21693,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -21467,25 +21737,35 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174) { + var errorBindingElement = ts.getAncestor(usage, 174); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224), usage); + } + else if (declaration.kind === 224) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: - case 213: + case 206: + case 212: + case 214: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: case 213: + case 214: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -21512,6 +21792,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -21525,7 +21814,7 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 279) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 144 || @@ -21548,13 +21837,13 @@ var ts; } } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 231: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { + if (location.kind === 262 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -21564,7 +21853,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + ts.getDeclarationOfKind(moduleExports[name], 244)) { break; } } @@ -21572,7 +21861,7 @@ var ts; break loop; } break; - case 229: + case 230: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } @@ -21588,9 +21877,9 @@ var ts; } } break; - case 226: - case 197: case 227: + case 197: + case 228: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -21608,7 +21897,7 @@ var ts; break; case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; @@ -21620,7 +21909,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; @@ -21684,7 +21973,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 234) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -21764,7 +22053,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -21781,10 +22070,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 235) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 236) { node = node.parent; } return node; @@ -21794,7 +22083,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 246) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -21898,19 +22187,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: + case 235: return getTargetOfImportEqualsDeclaration(node); - case 236: - return getTargetOfImportClause(node); case 237: + return getTargetOfImportClause(node); + case 238: return getTargetOfNamespaceImport(node); - case 239: - return getTargetOfImportSpecifier(node); - case 243: - return getTargetOfExportSpecifier(node); case 240: + return getTargetOfImportSpecifier(node); + case 244: + return getTargetOfExportSpecifier(node); + case 241: return getTargetOfExportAssignment(node); - case 233: + case 234: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21954,10 +22243,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 241) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 244) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21973,7 +22262,7 @@ var ts; return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 235); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -22270,11 +22559,11 @@ var ts; } } switch (location_1.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230: + case 231: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -22318,7 +22607,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22350,7 +22639,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22423,7 +22712,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22461,7 +22750,7 @@ var ts; meaning = 107455 | 1048576; } else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + entityName.parent.kind === 235) { meaning = 1920; } else { @@ -22556,7 +22845,7 @@ var ts; while (node.kind === 166) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 229) { return getSymbolOfNode(node); } } @@ -22564,7 +22853,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 232 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -22633,9 +22922,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22768,12 +23057,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -22832,7 +23121,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 262 || declaration.parent.kind === 232; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22845,25 +23134,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); @@ -22946,8 +23216,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -23126,6 +23396,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -23138,7 +23412,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -23156,6 +23429,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 134); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -23166,6 +23465,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -23182,27 +23482,27 @@ var ts; switch (node.kind) { case 174: return isDeclarationVisible(node.parent.parent); - case 223: + case 224: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: + case 231: case 227: case 228: - case 225: case 229: - case 234: + case 226: + case 230: + case 235: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 && parent_8.kind !== 262 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147: case 146: case 151: @@ -23217,7 +23517,7 @@ var ts; case 153: case 155: case 144: - case 231: + case 232: case 158: case 159: case 161: @@ -23228,15 +23528,15 @@ var ts; case 165: case 166: return isDeclarationVisible(node.parent); - case 236: case 237: - case 239: + case 238: + case 240: return false; case 143: - case 261: - case 233: + case 262: + case 234: return true; - case 240: + case 241: return false; default: return false; @@ -23245,10 +23545,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 241) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 244) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23326,12 +23626,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: case 224: + case 225: + case 240: case 239: case 238: case 237: - case 236: node = node.parent; break; default: @@ -23350,9 +23650,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); @@ -23487,11 +23784,11 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 213) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 214) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -23501,7 +23798,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23539,7 +23836,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (declaration.kind === 259) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23614,7 +23911,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 258) { return type; } return getWidenedType(type); @@ -23642,10 +23939,10 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 241) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 287 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -23852,8 +24149,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || + if (node.kind === 227 || node.kind === 197 || + node.kind === 226 || node.kind === 184 || node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { @@ -23863,15 +24160,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 228 || node.kind === 227 || + node.kind === 197 || node.kind === 229) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -24004,7 +24301,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -24033,7 +24330,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 228) { if (declaration.flags & 64) { return false; } @@ -24083,7 +24380,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 286); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24094,7 +24391,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 229); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24126,7 +24423,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24154,7 +24451,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24629,8 +24926,8 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -24901,7 +25198,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 274) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -24912,7 +25209,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 274; } } } @@ -24964,7 +25261,7 @@ var ts; var thisParameter = undefined; var hasThisParameter = void 0; var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -25047,12 +25344,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -25063,7 +25360,7 @@ var ts; case 152: case 184: case 185: - case 274: + case 275: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25335,7 +25632,7 @@ var ts; switch (node.kind) { case 157: return node.typeName; - case 272: + case 273: return node.name; case 199: var expr = node.expression; @@ -25361,7 +25658,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 273) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -25371,7 +25668,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 273) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -25406,9 +25703,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226: case 227: - case 229: + case 228: + case 230: return declaration; } } @@ -25582,8 +25879,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -25693,8 +25991,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -25812,7 +26110,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -25924,7 +26222,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -26047,7 +26345,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228)) { if (!(ts.getModifierFlags(container) & 32) && (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -26066,8 +26364,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: case 264: + case 265: return anyType; case 134: return stringType; @@ -26085,21 +26383,21 @@ var ts; return nullType; case 129: return neverType; - case 289: - return nullType; case 290: - return undefinedType; + return nullType; case 291: + return undefinedType; + case 292: return neverType; case 167: case 98: return getTypeFromThisTypeNode(node); case 171: return getTypeFromLiteralTypeNode(node); - case 288: + case 289: return getTypeFromLiteralTypeNode(node.literal); case 157: - case 272: + case 273: return getTypeFromTypeReference(node); case 156: return booleanType; @@ -26108,29 +26406,29 @@ var ts; case 160: return getTypeFromTypeQueryNode(node); case 162: - case 265: + case 266: return getTypeFromArrayTypeNode(node); case 163: return getTypeFromTupleTypeNode(node); case 164: - case 266: + case 267: return getTypeFromUnionTypeNode(node); case 165: return getTypeFromIntersectionTypeNode(node); case 166: - case 268: case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); case 270: + case 277: + case 278: + case 274: + return getTypeFromTypeNode(node.type); + case 271: return getTypeFromTypeNode(node.literal); case 158: case 159: case 161: - case 287: - case 274: + case 288: + case 275: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168: return getTypeFromTypeOperatorNode(node); @@ -26142,9 +26440,9 @@ var ts; case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 268: return getTypeFromJSDocTupleType(node); - case 275: + case 276: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26293,17 +26591,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -26324,12 +26624,12 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158: case 159: - case 225: + case 226: case 149: case 148: case 150: @@ -26340,10 +26640,10 @@ var ts; case 152: case 184: case 185: - case 226: - case 197: case 227: + case 197: case 228: + case 229: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26353,15 +26653,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 228) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 275: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231: + case 262: return false; } node = node.parent; @@ -26371,7 +26680,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 262 || parentKind === 232; } return false; } @@ -26438,7 +26747,7 @@ var ts; case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 258: return isContextSensitive(node.initializer); case 149: case 148: @@ -26494,7 +26803,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -27196,8 +27505,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -27348,7 +27660,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -27557,8 +27869,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27566,8 +27878,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27658,8 +27970,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -27818,7 +28130,7 @@ var ts; case 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 226: case 149: case 148: case 151: @@ -28159,8 +28471,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28276,7 +28588,7 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 224 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; @@ -28374,8 +28686,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -28461,7 +28773,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + return node.parent.kind === 175 || node.parent.kind === 258 ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -28480,9 +28792,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: - return stringType; case 213: + return stringType; + case 214: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192: return getAssignedTypeOfBinaryExpression(parent); @@ -28492,9 +28804,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196: return getAssignedTypeOfSpreadExpression(parent); - case 257: - return getAssignedTypeOfPropertyAssignment(parent); case 258: + return getAssignedTypeOfPropertyAssignment(parent); + case 259: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28517,26 +28829,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 213) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 214) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 224 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 224 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 224 && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); @@ -28563,7 +28875,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 254) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28665,8 +28977,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -29208,8 +29520,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || + node.kind === 232 || + node.kind === 262 || node.kind === 147) { return node; } @@ -29279,7 +29591,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 227 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29307,6 +29619,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -29334,7 +29647,7 @@ var ts; flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -29365,7 +29678,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 257) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -29383,8 +29696,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 212 && + ts.getAncestor(symbol.valueDeclaration, 225).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -29474,10 +29787,10 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 150: @@ -29535,9 +29848,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 275) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -29831,8 +30144,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -29902,13 +30215,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { + if (attribute.kind === 251) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251) { + else if (attribute.kind === 252) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -29926,14 +30239,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: + case 224: case 144: case 147: case 146: case 174: return getContextualTypeForInitializerExpression(node); case 185: - case 216: + case 217: return getContextualTypeForReturnExpression(node); case 195: return getContextualTypeForYieldOperand(parent); @@ -29945,22 +30258,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192: return getContextualTypeForBinaryOperand(node); - case 257: case 258: + case 259: return getContextualTypeForObjectLiteralElement(parent); case 175: return getContextualTypeForElementExpression(node); case 193: return getContextualTypeForConditionalOperand(node); - case 202: + case 203: ts.Debug.assert(parent.parent.kind === 194); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183: return getContextualType(parent); - case 252: + case 253: return getContextualType(parent); - case 250: case 251: + case 252: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -30012,8 +30325,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -30156,25 +30469,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 258 || + memberDecl.kind === 259 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 258) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 259); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -30200,7 +30513,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { + else if (memberDecl.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(memberDecl, 2); } @@ -30300,13 +30613,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 253: checkJsxExpression(child); break; - case 246: + case 247: checkJsxElement(child); break; - case 247: + case 248: checkJsxSelfClosingElement(child); break; } @@ -30601,11 +30914,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { + if (node.attributes[i].kind === 251) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251); + ts.Debug.assert(node.attributes[i].kind === 252); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -30624,7 +30937,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -30642,7 +30959,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 177 || node.kind === 224 ? node.name : node.right; if (left.kind === 96) { @@ -30788,7 +31105,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 225) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -30810,7 +31127,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 213 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30906,19 +31223,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -31138,7 +31455,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145) { switch (node.parent.kind) { - case 226: + case 227: case 197: return 1; case 147: @@ -31159,7 +31476,7 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -31180,7 +31497,7 @@ var ts; return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -31217,7 +31534,7 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 227) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -31578,7 +31895,7 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: + case 227: case 197: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144: @@ -31688,9 +32005,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 226 : resolvedRequire.flags & 3 - ? 223 + ? 224 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31716,6 +32033,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -31823,7 +32157,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 205) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -31902,7 +32236,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -31948,7 +32282,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -32014,6 +32348,7 @@ var ts; if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -32028,7 +32363,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 205) { checkSourceElement(node.body); } else { @@ -32081,7 +32416,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 238; } } } @@ -32097,6 +32432,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 && expr.kind !== 178) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -32167,8 +32512,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -32182,8 +32527,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -32192,8 +32537,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -32240,7 +32585,7 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { + if (property.kind === 258 || property.kind === 259) { var name_22 = property.name; if (name_22.kind === 142) { checkComputedPropertyName(name_22); @@ -32255,7 +32600,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 259) { return checkDestructuringAssignment(property, type); } else { @@ -32266,7 +32611,7 @@ var ts; error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); } } - else if (property.kind === 259) { + else if (property.kind === 260) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32334,7 +32679,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 259) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -32362,7 +32707,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 260 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32391,8 +32736,8 @@ var ts; case 176: case 187: case 201: + case 248: case 247: - case 246: return true; case 193: return isSideEffectFree(node.whenTrue) && @@ -32826,6 +33171,8 @@ var ts; return checkAssertion(node); case 201: return checkNonNullAssertion(node); + case 202: + return checkMetaProperty(node); case 186: return checkDeleteExpression(node); case 188: @@ -32846,13 +33193,13 @@ var ts; return undefinedWideningType; case 195: return checkYieldExpression(node); - case 252: + case 253: return checkJsxExpression(node); - case 246: - return checkJsxElement(node); case 247: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 248: + return checkJsxSelfClosingElement(node); + case 249: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -32897,7 +33244,7 @@ var ts; return false; } return node.kind === 149 || - node.kind === 225 || + node.kind === 226 || node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -32956,14 +33303,14 @@ var ts; switch (node.parent.kind) { case 185: case 153: - case 225: + case 226: case 184: case 158: case 149: case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -32991,7 +33338,7 @@ var ts; if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || + else if (node.kind === 158 || node.kind === 226 || node.kind === 159 || node.kind === 153 || node.kind === 150 || node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); @@ -33113,7 +33460,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 228) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -33195,7 +33542,7 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 184 && n.kind !== 226) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -33220,7 +33567,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33369,8 +33716,8 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && + if (n.parent.kind !== 228 && + n.parent.kind !== 227 && n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { @@ -33481,11 +33828,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 226 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33596,16 +33943,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 228: return 2097152; - case 230: + case 231: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 227: + case 230: return 2097152 | 1048576; - case 234: + case 235: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33617,7 +33964,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -33752,7 +34100,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 227: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -33807,7 +34155,7 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 227: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33840,6 +34188,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33890,28 +34239,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 262: + case 231: checkUnusedModuleMembers(node); break; - case 226: + case 227: case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 228: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: + case 205: + case 233: case 212: case 213: + case 214: checkUnusedLocalsAndParameters(node); break; case 150: case 184: - case 225: + case 226: case 185: case 149: case 151: @@ -33935,7 +34284,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -33968,9 +34317,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 224 && + (declaration.parent.parent.kind === 213 || + declaration.parent.parent.kind === 214)) { return; } } @@ -34031,7 +34380,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -34039,7 +34388,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 205) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34083,6 +34432,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -34099,6 +34453,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -34108,8 +34478,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -34124,11 +34494,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34136,11 +34506,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 231 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 262 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34148,7 +34518,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 224 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -34158,15 +34528,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225); + var container = varDeclList.parent.kind === 206 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || + (container.kind === 205 && ts.isFunctionLike(container.parent) || + container.kind === 232 || container.kind === 231 || - container.kind === 230 || - container.kind === 261); + container.kind === 262); if (!namesShareScope) { var name_25 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); @@ -34199,7 +34569,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 144 || + symbol.valueDeclaration.kind === 174) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -34237,19 +34608,19 @@ var ts; } } if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.parent.kind === 172 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_26 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -34260,7 +34631,7 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34269,7 +34640,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 213) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34289,18 +34660,19 @@ var ts; } if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 224 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 144 && right.kind === 224) || + (left.kind === 224 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34346,7 +34718,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 207) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34363,12 +34735,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 225) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34386,7 +34758,7 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { checkForInOrForOfVariableDeclaration(node); } else { @@ -34411,7 +34783,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 225) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -34668,7 +35040,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 255 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34680,7 +35052,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 254) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34706,7 +35078,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 220 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -34829,7 +35201,7 @@ var ts; } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -34849,7 +35221,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { + if (declaration.kind === 227 || declaration.kind === 228) { if (!firstDecl) { firstDecl = declaration; } @@ -34882,6 +35254,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -34917,7 +35290,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 227) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -35044,7 +35417,7 @@ var ts; if (!list1 || !list2 || list1.length !== list2.length) { return false; } - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -35102,7 +35475,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35233,6 +35606,7 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; case 183: return evalConstant(e.expression); @@ -35306,6 +35680,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -35326,7 +35701,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 230) { return false; } var enumDeclaration = declaration; @@ -35349,8 +35724,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 || + (declaration.kind === 226 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35409,7 +35784,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 227); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35452,22 +35827,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 206: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: case 241: + case 242: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: case 235: + case 236: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174: - case 223: + case 224: var name_27 = node.name; if (ts.isBindingPattern(name_27)) { for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { @@ -35476,12 +35851,12 @@ var ts; } break; } - case 226: - case 229: - case 225: case 227: case 230: + case 226: case 228: + case 231: + case 229: if (isGlobalAugmentation) { return; } @@ -35517,9 +35892,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35540,7 +35915,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 244 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -35567,7 +35942,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { checkImportBinding(importClause.namedBindings); } else { @@ -35618,8 +35993,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35632,7 +36007,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 262 || node.parent.kind === 232 || node.parent.kind === 231; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35655,9 +36030,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 ? node.parent : node.parent.parent; + if (container.kind === 231 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -35723,7 +36103,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 226 && declaration.kind !== 149) || !!declaration.body; } } @@ -35734,10 +36114,10 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -35786,71 +36166,71 @@ var ts; return checkIndexedAccessType(node); case 170: return checkMappedType(node); - case 225: + case 226: return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); case 205: + case 232: + return checkBlock(node); + case 206: return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); case 208: - return checkIfStatement(node); + return checkExpressionStatement(node); case 209: - return checkDoStatement(node); + return checkIfStatement(node); case 210: - return checkWhileStatement(node); + return checkDoStatement(node); case 211: - return checkForStatement(node); + return checkWhileStatement(node); case 212: - return checkForInStatement(node); + return checkForStatement(node); case 213: - return checkForOfStatement(node); + return checkForInStatement(node); case 214: + return checkForOfStatement(node); case 215: - return checkBreakOrContinueStatement(node); case 216: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 217: - return checkWithStatement(node); + return checkReturnStatement(node); case 218: - return checkSwitchStatement(node); + return checkWithStatement(node); case 219: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 220: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 221: + return checkThrowStatement(node); + case 222: return checkTryStatement(node); - case 223: + case 224: return checkVariableDeclaration(node); case 174: return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 228: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 229: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 230: + return checkEnumDeclaration(node); + case 231: return checkModuleDeclaration(node); - case 235: + case 236: return checkImportDeclaration(node); - case 234: + case 235: return checkImportEqualsDeclaration(node); - case 241: + case 242: return checkExportDeclaration(node); - case 240: + case 241: return checkExportAssignment(node); - case 206: + case 207: checkGrammarStatementInAmbientContext(node); return; - case 222: + case 223: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 245: return checkMissingDeclaration(node); } } @@ -35893,6 +36273,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -35912,6 +36293,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -35956,7 +36341,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 218 && node.parent.statement === node) { return true; } node = node.parent; @@ -35978,14 +36363,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 262: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; case 197: @@ -35993,8 +36378,8 @@ var ts; if (className) { copySymbol(location.symbol, meaning); } - case 226: case 227: + case 228: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } @@ -36039,10 +36424,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143: - case 226: case 227: case 228: case 229: + case 230: return true; } } @@ -36051,7 +36436,7 @@ var ts; while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 273); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -36078,10 +36463,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 235) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 241) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -36105,11 +36490,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + var importEqualsDeclaration = ts.getAncestor(entityName, 235); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -36156,10 +36541,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 273) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 251) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156) { @@ -36168,7 +36553,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 262) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36221,7 +36606,7 @@ var ts; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 236 || node.parent.kind === 242) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36243,7 +36628,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 259) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36294,7 +36679,7 @@ var ts; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + if (expr.parent.kind === 214) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -36302,7 +36687,7 @@ var ts; var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 258) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -36413,7 +36798,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 262) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -36451,7 +36836,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 205 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36491,16 +36876,16 @@ var ts; return true; } switch (node.kind) { - case 234: - case 236: + case 235: case 237: - case 239: - case 243: + case 238: + case 240: + case 244: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241: + case 242: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 241: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -36510,7 +36895,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36561,7 +36946,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 261) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36655,9 +37040,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36770,15 +37155,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36797,7 +37182,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 262); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -36974,7 +37359,7 @@ var ts; } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 230 && node.parent.kind === 227) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -37000,7 +37385,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -37023,7 +37408,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 232 || node.parent.kind === 262) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144) { @@ -37058,7 +37443,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144) { @@ -37073,13 +37458,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -37089,14 +37474,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { + if (node.kind !== 227) { if (node.kind !== 149 && node.kind !== 147 && node.kind !== 151 && node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 227 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37138,7 +37523,7 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 236 || node.kind === 235) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { @@ -37168,29 +37553,29 @@ var ts; case 149: case 148: case 155: - case 230: + case 231: + case 236: case 235: - case 234: + case 242: case 241: - case 240: case 184: case 185: case 144: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 232 || node.parent.kind === 262) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); case 226: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 119); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 116); case 228: - return true; + case 206: case 229: + return true; + case 230: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -37204,7 +37589,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149: - case 225: + case 226: case 184: case 185: if (!node.asteriskToken) { @@ -37410,7 +37795,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || + ts.Debug.assert(node.kind === 226 || node.kind === 184 || node.kind === 149); if (ts.isInAmbientContext(node)) { @@ -37437,14 +37822,14 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 260) { continue; } var name_30 = prop.name; if (name_30.kind === 142) { checkGrammarComputedPropertyName(name_30); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { @@ -37456,7 +37841,7 @@ var ts; } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 258 || prop.kind === 259) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_30.kind === 8) { checkGrammarNumericLiteral(name_30); @@ -37505,7 +37890,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 252) { continue; } var jsxAttr = attr; @@ -37517,7 +37902,7 @@ var ts; return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 253 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37526,7 +37911,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 225) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37534,20 +37919,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 213 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -37631,7 +38016,7 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } else if (node.parent.kind === 161) { @@ -37645,9 +38030,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 220: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 215 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -37655,8 +38040,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 219: + if (node.kind === 216 && !node.label) { return false; } break; @@ -37669,13 +38054,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 216 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 215 + var message = node.kind === 216 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -37701,7 +38086,7 @@ var ts; expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 213 && node.parent.parent.kind !== 214) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37758,15 +38143,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: case 209: case 210: - case 217: case 211: + case 218: case 212: case 213: + case 214: return false; - case 219: + case 220: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -37781,6 +38166,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -37821,7 +38213,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 228) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37842,13 +38234,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 228 || + node.kind === 229 || + node.kind === 236 || node.kind === 235 || - node.kind === 234 || + node.kind === 242 || node.kind === 241 || - node.kind === 240 || - node.kind === 233 || + node.kind === 234 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -37857,7 +38249,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 205) { + if (ts.isDeclaration(decl) || decl.kind === 206) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -37876,7 +38268,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 205 || node.parent.kind === 232 || node.parent.kind === 262) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -37887,8 +38279,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -37933,31 +38339,31 @@ var ts; _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230] = [ + _a[231] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231] = [ + _a[232] = [ { name: "statements", test: ts.isStatement } ], - _a[234] = [ + _a[235] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245] = [ + _a[246] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260] = [ + _a[261] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -37983,11 +38389,11 @@ var ts; } var result = initial; switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: - case 293: + case 223: + case 294: break; case 142: result = reduceNode(node.expression, cbNode, result); @@ -38128,72 +38534,72 @@ var ts; result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 202: + case 203: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 205: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 206: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 208: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 209: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 211: + case 218: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 212: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: case 213: + case 214: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 217: + case 221: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 219: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 220: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 222: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 224: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 225: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 226: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38202,7 +38608,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38210,92 +38616,92 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232: + case 233: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 237: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 239: case 243: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 240: + case 244: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240: + case 241: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: case 248: + case 249: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249: + case 250: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 251: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; case 252: result = reduceNode(node.expression, cbNode, result); break; case 253: result = reduceNode(node.expression, cbNode, result); + break; case 254: + result = reduceNode(node.expression, cbNode, result); + case 255: result = reduceNodes(node.statements, cbNodes, result); break; - case 255: + case 256: result = reduceNodes(node.types, cbNodes, result); break; - case 256: + case 257: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 258: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 259: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 260: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 262: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 295: result = reduceNode(node.expression, cbNode, result); break; default: @@ -38436,10 +38842,10 @@ var ts; return node; } switch (node.kind) { - case 203: - case 206: + case 204: + case 207: case 198: - case 222: + case 223: return node; case 142: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); @@ -38507,101 +38913,101 @@ var ts; return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); case 199: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 202: + case 203: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 204: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 205: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 206: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 221: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 222: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 226: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 227: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232: + case 233: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 243: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 244: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 259: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 260: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 261: + case 262: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 295: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -38689,7 +39095,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 199)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -39093,15 +39499,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: + case 262: + case 233: case 232: - case 231: - case 204: + case 205: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 227: case 226: - case 225: if (ts.hasModifier(node, 2)) { break; } @@ -39126,13 +39532,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 240: - return visitExportAssignment(node); case 241: + return visitExportAssignment(node); + case 242: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39142,11 +39548,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || + if (node.kind === 242 || node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + node.kind === 237 || + (node.kind === 235 && + node.moduleReference.kind === 246)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39170,7 +39576,7 @@ var ts; case 152: case 149: return visitorWorker(node); - case 203: + case 204: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39227,18 +39633,18 @@ var ts; case 171: case 155: case 145: - case 228: + case 229: case 147: return undefined; case 150: return visitConstructor(node); - case 227: + case 228: return ts.createNotEmittedStatement(node); - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); - case 255: + case 256: return visitHeritageClause(node); case 199: return visitExpressionWithTypeArguments(node); @@ -39248,7 +39654,7 @@ var ts; return visitGetAccessor(node); case 152: return visitSetAccessor(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -39267,15 +39673,15 @@ var ts; return visitNewExpression(node); case 201: return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); case 230: + return visitEnumDeclaration(node); + case 206: + return visitVariableStatement(node); + case 224: + return visitVariableDeclaration(node); + case 231: return visitModuleDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39429,7 +39835,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39714,7 +40120,7 @@ var ts; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: + case 227: case 197: return ts.getFirstConstructorWithBody(node) !== undefined; case 149: @@ -39732,7 +40138,7 @@ var ts; return serializeTypeNode(node.type); case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: + case 227: case 197: case 149: return ts.createIdentifier("Function"); @@ -39789,6 +40195,9 @@ var ts; } switch (node.kind) { case 104: + case 137: + case 94: + case 129: return ts.createVoidZero(); case 166: return serializeTypeNode(node.type); @@ -39827,29 +40236,7 @@ var ts; return serializeTypeReferenceNode(node); case 165: case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } + return serializeUnionOrIntersectionType(node); case 160: case 168: case 169: @@ -39864,6 +40251,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -40190,7 +40603,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 230) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -40250,8 +40663,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -40273,13 +40686,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + if (body.kind !== 232) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 231) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40299,7 +40712,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 238) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40434,15 +40847,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(259); + context.enableEmitNotification(231); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 231; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 230; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -40515,9 +40928,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 262) { + var substitute = (applicableSubstitutions & 2 && container.kind === 231) || + (applicableSubstitutions & 8 && container.kind === 230); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -40632,11 +41045,11 @@ var ts; return visitObjectLiteralExpression(node); case 192: return visitBinaryExpression(node, noDestructuringValue); - case 223: + case 224: return visitVariableDeclaration(node); - case 213: + case 214: return visitForOfStatement(node); - case 211: + case 212: return visitForStatement(node); case 188: return visitVoidExpression(node); @@ -40648,7 +41061,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152: return visitSetAccessorDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -40656,7 +41069,7 @@ var ts; return visitArrowFunction(node); case 144: return visitParameter(node); - case 207: + case 208: return visitExpressionStatement(node); case 183: return visitParenthesizedExpression(node, noDestructuringValue); @@ -40669,7 +41082,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259) { + if (e.kind === 260) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40681,7 +41094,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 258) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40854,11 +41267,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: - return visitJsxElement(node, false); case 247: + return visitJsxElement(node, false); + case 248: return visitJsxSelfClosingElement(node, false); - case 252: + case 253: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40868,11 +41281,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 253: return visitJsxExpression(node); - case 246: - return visitJsxElement(node, true); case 247: + return visitJsxElement(node, true); + case 248: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -40926,7 +41339,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 252) { + else if (node.kind === 253) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -40991,7 +41407,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 247) { return getTagName(node.openingElement); } else { @@ -41310,7 +41726,7 @@ var ts; return visitAwaitExpression(node); case 149: return visitMethodDeclaration(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -41409,7 +41825,7 @@ var ts; context.enableSubstitution(179); context.enableSubstitution(177); context.enableSubstitution(178); - context.enableEmitNotification(226); + context.enableEmitNotification(227); context.enableEmitNotification(149); context.enableEmitNotification(151); context.enableEmitNotification(152); @@ -41465,7 +41881,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 + return kind === 227 || kind === 150 || kind === 149 || kind === 151 @@ -41604,15 +42020,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -41622,178 +42030,104 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 217 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 227: return visitClassDeclaration(node); case 197: return visitClassExpression(node); case 144: return visitParameter(node); - case 225: + case 226: return visitFunctionDeclaration(node); case 185: return visitArrowFunction(node); case 184: return visitFunctionExpression(node); - case 223: + case 224: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 225: return visitVariableDeclarationList(node); case 219: + return visitSwitchStatement(node); + case 233: + return visitCaseBlock(node); + case 205: + return visitBlock(node, false); + case 216: + case 215: + return visitBreakOrContinueStatement(node); + case 220: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); + return visitDoOrWhileStatement(node, undefined); case 212: - return visitForInStatement(node); + return visitForStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForInStatement(node, undefined); + case 214: + return visitForOfStatement(node, undefined); + case 208: return visitExpressionStatement(node); case 176: return visitObjectLiteralExpression(node); - case 256: + case 257: return visitCatchClause(node); - case 258: + case 259: return visitShorthandPropertyAssignment(node); + case 142: + return visitComputedPropertyName(node); case 175: return visitArrayLiteralExpression(node); case 179: @@ -41818,51 +42152,80 @@ var ts; case 196: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 202: + return visitMetaProperty(node); case 149: return visitMethodDeclaration(node); - case 205: + case 151: + case 152: + return visitAccessorDeclaration(node); + case 206: return visitVariableStatement(node); + case 217: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0, 0); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -41878,13 +42241,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; + var jump = node.kind === 216 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 216) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -41894,7 +42257,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 216) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -41993,6 +42356,9 @@ var ts; } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); @@ -42000,6 +42366,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -42020,23 +42388,26 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { ts.setEmitFlags(block, 1536); @@ -42044,17 +42415,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 217) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 209) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 205) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -42062,8 +42433,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -42083,9 +42454,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression @@ -42100,17 +42470,17 @@ var ts; statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -42206,21 +42576,53 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 185: + return statements; + case 149: + case 151: + case 152: + newTarget = ts.createVoidZero(); + break; + case 150: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 226: + case 184: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 204: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151: case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150: @@ -42234,26 +42636,29 @@ var ts; function transformSemicolonClassElementToStatement(member) { return ts.createEmptyStatement(member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false), ts.getSourceMapRange(accessors.firstAccessor)); ts.setEmitFlags(statement, 1536); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -42262,7 +42667,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -42270,7 +42675,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -42286,35 +42691,69 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 226 || node.kind === 184)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body, location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -42361,6 +42800,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } @@ -42374,6 +42814,21 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { case 183: @@ -42398,9 +42853,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -42417,49 +42875,54 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -42475,48 +42938,51 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; @@ -42579,31 +43045,53 @@ var ts; ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); ts.setEmitFlags(forStatement, 256); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210: + case 211: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212: + return visitForStatement(node, outermostLabeledStatement); + case 213: + return visitForInStatement(node, outermostLabeledStatement); + case 214: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -42627,14 +43115,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -42643,11 +43133,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: case 212: case 213: + case 214: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 225) { loopInitializer = initializer; } break; @@ -42674,7 +43164,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -42686,11 +43176,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, undefined, true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], undefined, true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -42749,19 +43241,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -42875,17 +43366,17 @@ var ts; case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: - expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + case 149: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; case 258: - expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + case 259: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -42907,21 +43398,31 @@ var ts; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container), method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -42929,21 +43430,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; + } function visitShorthandPropertyAssignment(node) { return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; + } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -42955,25 +43478,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -43071,21 +43596,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -43103,7 +43641,7 @@ var ts; context.enableEmitNotification(152); context.enableEmitNotification(185); context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } function onSubstituteNode(emitContext, node) { @@ -43129,9 +43667,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174: - case 226: - case 229: - case 223: + case 227: + case 230: + case 224: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43157,8 +43695,7 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { + && hierarchyFacts & 16) { return ts.createIdentifier("_this", node); } return node; @@ -43175,7 +43712,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208) { return false; } var statementExpression = statement.expression; @@ -43206,7 +43743,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; @@ -43283,13 +43820,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 218: - return visitSwitchStatement(node); case 219: + return visitSwitchStatement(node); + case 220: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43297,24 +43834,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); case 151: case 152: return visitAccessorDeclaration(node); - case 205: + case 206: return visitVariableStatement(node); - case 211: - return visitForStatement(node); case 212: + return visitForStatement(node); + case 213: return visitForInStatement(node); - case 215: - return visitBreakStatement(node); - case 214: - return visitContinueStatement(node); case 216: + return visitBreakStatement(node); + case 215: + return visitContinueStatement(node); + case 217: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43352,7 +43889,7 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 226: return visitFunctionDeclaration(node); case 184: return visitFunctionExpression(node); @@ -43539,10 +44076,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -43604,7 +44141,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -43664,10 +44201,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -43710,35 +44247,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 205: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 212: + return transformAndEmitForStatement(node); + case 213: return transformAndEmitForInStatement(node); - case 214: - return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 221: + return transformAndEmitThrowStatement(node); + case 222: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -43758,7 +44295,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_39 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_39, variable.name); + hoistVariableDeclaration(name_39); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -43788,7 +44327,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -44022,7 +44561,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 255 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44032,7 +44571,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 254) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44153,12 +44692,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_6 = ts.getMutableClone(name_39); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_40 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_40) { + var clone_7 = ts.getMutableClone(name_40); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -44768,41 +45307,41 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)]), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)]), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ]), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -44827,15 +45366,40 @@ var ts; var ts; (function (ts) { function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249); + context.enableEmitNotification(250); + context.enableEmitNotification(248); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177); - context.enableSubstitution(257); + context.enableSubstitution(258); return transformSourceFile; function transformSourceFile(node) { return node; } + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249: + case 250: + case 248: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -44892,8 +45456,8 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); + context.enableSubstitution(259); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var currentSourceFile; @@ -44931,14 +45495,7 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; return ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ @@ -44952,6 +45509,36 @@ var ts; ]))) ], node.statements)); } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], undefined, true)); + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ], node.statements)); + } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; var unaliasedModuleNames = []; @@ -45011,23 +45598,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return visitExportDeclaration(node); - case 240: + case 241: return visitExportAssignment(node); - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return node; @@ -45225,7 +45812,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -45257,10 +45844,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45368,7 +45955,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -45428,7 +46015,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -45437,8 +46024,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_40 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); + var name_41 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_41), node); } } } @@ -45502,7 +46089,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -45519,7 +46105,7 @@ var ts; context.enableSubstitution(192); context.enableSubstitution(190); context.enableSubstitution(191); - context.enableEmitNotification(261); + context.enableEmitNotification(262); var moduleInfoMap = ts.createMap(); var deferredExports = ts.createMap(); var exportFunctionsMap = ts.createMap(); @@ -45619,7 +46205,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 242 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -45642,7 +46228,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 242) { continue; } var exportDecl = externalImport; @@ -45694,15 +46280,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 236: if (!entry.importClause) { break; } - case 234: + case 235: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 242: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -45724,13 +46310,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 236: return visitImportDeclaration(node); - case 234: + case 235: return visitImportEqualsDeclaration(node); - case 241: + case 242: return undefined; - case 240: + case 241: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -45851,7 +46437,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 262 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -45873,7 +46459,7 @@ var ts; : preventSubstitution(ts.createAssignment(name, value, location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -45906,10 +46492,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 238: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 239: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -46008,43 +46594,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 206: return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); case 226: + return visitFunctionDeclaration(node); + case 227: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitForStatement(node); case 213: + return visitForInStatement(node); + case 214: return visitForOfStatement(node); - case 209: - return visitDoStatement(node); case 210: + return visitDoStatement(node); + case 211: return visitWhileStatement(node); - case 219: + case 220: return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); case 218: + return visitWithStatement(node); + case 219: return visitSwitchStatement(node); - case 232: + case 233: return visitCaseBlock(node); - case 253: - return visitCaseClause(node); case 254: + return visitCaseClause(node); + case 255: return visitDefaultClause(node); - case 221: + case 222: return visitTryStatement(node); - case 256: + case 257: return visitCatchClause(node); - case 204: + case 205: return visitBlock(node); - case 295: - return visitMergeDeclarationMarker(node); case 296: + return visitMergeDeclarationMarker(node); + case 297: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46172,7 +46758,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 262; } else { return false; @@ -46187,7 +46773,7 @@ var ts; return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + if (node.kind === 262) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46299,7 +46885,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 262) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46327,7 +46913,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.enableEmitNotification(262); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -46352,9 +46938,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234: + case 235: return undefined; - case 240: + case 241: return visitExportAssignment(node); } return node; @@ -46663,7 +47249,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 236); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -46735,10 +47321,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 224) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 239 || declaration.kind === 240 || declaration.kind === 237) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -46749,7 +47335,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 236) { moduleElementEmitInfo.isVisible = true; } else { @@ -46757,12 +47343,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 231) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -46933,7 +47519,7 @@ var ts; } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 235 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -47050,9 +47636,9 @@ var ts; var count = 0; while (true) { count++; - var name_41 = baseName + "_" + count; - if (!(name_41 in currentIdentifiers)) { - return name_41; + var name_42 = baseName + "_" + count; + if (!(name_42 in currentIdentifiers)) { + return name_42; } } } @@ -47096,10 +47682,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 235 || + (node.parent.kind === 262 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47108,7 +47694,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 236) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47126,30 +47712,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); - case 227: - return writeInterfaceDeclaration(node); case 226: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 206: + return writeVariableStatement(node); case 228: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 227: + return writeClassDeclaration(node); case 229: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 230: + return writeEnumDeclaration(node); + case 231: return writeModuleDeclaration(node); - case 234: - return writeImportEqualsDeclaration(node); case 235: + return writeImportEqualsDeclaration(node); + case 236: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 262) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47157,7 +47743,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 228 && !noDeclare) { write("declare "); } } @@ -47207,7 +47793,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47230,7 +47816,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 238) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47247,13 +47833,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 235) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 231) { moduleSpecifier = parent.name; } else { @@ -47321,7 +47907,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 232) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -47419,10 +48005,10 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154: @@ -47436,17 +48022,17 @@ var ts; if (ts.hasModifier(node.parent, 32)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 227) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 225: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47483,7 +48069,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 227) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -47566,7 +48152,7 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -47589,7 +48175,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 224) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47604,7 +48190,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47764,13 +48350,13 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 226) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 226) { write("function "); writeTextOfNode(currentText, node.name); } @@ -47864,7 +48450,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 227) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47877,7 +48463,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 226: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47954,7 +48540,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 227) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47966,7 +48552,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 225: + case 226: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -48018,19 +48604,19 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: - case 227: case 226: - case 228: - case 229: - return emitModuleElement(node, isModuleElementVisible(node)); - case 205: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: case 235: + case 228: + case 227: + case 229: + case 230: + return emitModuleElement(node, isModuleElementVisible(node)); + case 206: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 236: return emitModuleElement(node, !node.importClause); - case 241: + case 242: return emitExportDeclaration(node); case 150: case 149: @@ -48046,11 +48632,11 @@ var ts; case 147: case 146: return emitPropertyDeclaration(node); - case 260: - return emitEnumMemberDeclaration(node); - case 240: - return emitExportAssignment(node); case 261: + return emitEnumMemberDeclaration(node); + case 241: + return emitExportAssignment(node); + case 262: return emitSourceFile(node); } } @@ -48267,7 +48853,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -48280,7 +48866,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 + if (node.kind !== 294 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -48424,7 +49010,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 294; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -48438,7 +49024,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 225) { declarationListContainerEnd = end; } } @@ -48794,7 +49380,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 261: + case 262: return emitSourceFile(node); } } @@ -48917,119 +49503,119 @@ var ts; return emitArrayBindingPattern(node); case 174: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); case 203: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 204: - return emitBlock(node); + return emitSemicolonClassElement(); case 205: - return emitVariableStatement(node); + return emitBlock(node); case 206: - return emitEmptyStatement(); + return emitVariableStatement(node); case 207: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 208: - return emitIfStatement(node); + return emitExpressionStatement(node); case 209: - return emitDoStatement(node); + return emitIfStatement(node); case 210: - return emitWhileStatement(node); + return emitDoStatement(node); case 211: - return emitForStatement(node); + return emitWhileStatement(node); case 212: - return emitForInStatement(node); + return emitForStatement(node); case 213: - return emitForOfStatement(node); + return emitForInStatement(node); case 214: - return emitContinueStatement(node); + return emitForOfStatement(node); case 215: - return emitBreakStatement(node); + return emitContinueStatement(node); case 216: - return emitReturnStatement(node); + return emitBreakStatement(node); case 217: - return emitWithStatement(node); + return emitReturnStatement(node); case 218: - return emitSwitchStatement(node); + return emitWithStatement(node); case 219: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 220: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 221: - return emitTryStatement(node); + return emitThrowStatement(node); case 222: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 223: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 226: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 227: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 231: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 232: + return emitModuleBlock(node); + case 233: return emitCaseBlock(node); - case 234: - return emitImportEqualsDeclaration(node); case 235: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 236: - return emitImportClause(node); + return emitImportDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportClause(node); case 238: - return emitNamedImports(node); + return emitNamespaceImport(node); case 239: - return emitImportSpecifier(node); + return emitNamedImports(node); case 240: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 241: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 242: - return emitNamedExports(node); + return emitExportDeclaration(node); case 243: - return emitExportSpecifier(node); + return emitNamedExports(node); case 244: - return; + return emitExportSpecifier(node); case 245: + return; + case 246: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); case 249: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 252: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxExpression(node); case 254: - return emitDefaultClause(node); + return emitCaseClause(node); case 255: - return emitHeritageClause(node); + return emitDefaultClause(node); case 256: - return emitCatchClause(node); + return emitHeritageClause(node); case 257: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 259: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 260: + return emitSpreadAssignment(node); + case 261: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -49106,14 +49692,14 @@ var ts; return emitAsExpression(node); case 201: return emitNonNullExpression(node); - case 246: - return emitJsxElement(node); + case 202: + return emitMetaProperty(node); case 247: + return emitJsxElement(node); + case 248: return emitJsxSelfClosingElement(node); - case 294: + case 295: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); } } function emitNumericLiteral(node) { @@ -49558,6 +50144,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -49600,27 +50191,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 209) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -49630,7 +50221,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49642,7 +50233,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49652,7 +50243,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49662,11 +50253,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 225) { emit(node); } else { @@ -49693,7 +50284,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -49717,9 +50308,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -49895,7 +50489,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 231) { write("."); emit(body.name); body = body.body; @@ -50046,6 +50640,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -50245,8 +50842,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -50375,6 +50972,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -50555,21 +51160,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_42 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_42)) { + var name_43 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_43)) { tempFlags |= flags; - return name_42; + return name_43; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_43 = count < 26 + var name_44 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_43)) { - return name_43; + if (isUniqueName(name_44)) { + return name_44; } } } @@ -50603,22 +51208,32 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); + case 231: case 230: - case 229: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 236: + case 242: return generateNameForImportOrExportDeclaration(node); - case 225: case 226: - case 240: + case 227: + case 241: return generateNameForExportDefault(); case 197: return generateNameForClassExpression(); + case 149: + case 151: + case 152: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } @@ -50649,11 +51264,14 @@ var ts; } return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } function getGeneratedIdentifier(name) { if (name.autoGenerateKind === 4) { var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { var autoGenerateId = name.autoGenerateId; @@ -50722,7 +51340,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -50905,10 +51524,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_44 = names_1[_i]; - var result = name_44 in cache - ? cache[name_44] - : cache[name_44] = loader(name_44, containingFile); + var name_45 = names_1[_i]; + var result = name_45 in cache + ? cache[name_45] + : cache[name_45] = loader(name_45, containingFile); resolutions.push(result); } return resolutions; @@ -50933,6 +51552,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -50945,7 +51565,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -50981,6 +51602,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -51187,7 +51809,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -51345,42 +51967,42 @@ var ts; case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: - case 223: + case 226: + case 224: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 235: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 241: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 256: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 228: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182: @@ -51398,23 +52020,23 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: + case 227: case 149: case 148: case 150: case 151: case 152: case 184: - case 225: + case 226: case 185: - case 225: + case 226: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 206: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 206); } break; case 147: @@ -51526,7 +52148,7 @@ var ts; && !file.isDeclarationFile) { var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); + var importDecl = ts.createSynthesizedNode(236); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -51544,9 +52166,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 236: case 235: - case 234: - case 241: + case 242: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51558,7 +52180,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 231: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -52182,32 +52804,32 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 144: - case 223: + case 224: case 174: case 147: case 146: - case 257: case 258: - case 260: + case 259: + case 261: case 149: case 148: case 150: case 151: case 152: - case 225: + case 226: case 184: case 185: - case 256: + case 257: return 1; case 143: - case 227: case 228: + case 229: case 161: return 2; - case 226: - case 229: - return 1 | 2; + case 227: case 230: + return 1 | 2; + case 231: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -52217,21 +52839,21 @@ var ts; else { return 4; } - case 238: case 239: - case 234: - case 235: case 240: + case 235: + case 236: case 241: + case 242: return 1 | 2 | 4; - case 261: + case 262: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240) { + if (node.parent.kind === 241) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -52255,7 +52877,7 @@ var ts; ts.Debug.assert(node.kind === 70); if (node.parent.kind === 141 && node.parent.right === node && - node.parent.parent.kind === 234) { + node.parent.parent.kind === 235) { return 1 | 2 | 4; } return 4; @@ -52289,10 +52911,10 @@ var ts; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 255) { + if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 256) { var decl = root.parent.parent.parent; - return (decl.kind === 226 && root.parent.parent.token === 107) || - (decl.kind === 227 && root.parent.parent.token === 84); + return (decl.kind === 227 && root.parent.parent.token === 107) || + (decl.kind === 228 && root.parent.parent.token === 84); } return false; } @@ -52323,7 +52945,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 220 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -52333,13 +52955,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 215 || node.parent.kind === 214) && + (node.parent.kind === 216 || node.parent.kind === 215) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 219 && + node.parent.kind === 220 && node.parent.label === node; } function isLabelName(node) { @@ -52355,7 +52977,7 @@ var ts; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 && node.parent.name === node; + return node.parent.kind === 231 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -52368,13 +52990,13 @@ var ts; switch (node.parent.kind) { case 147: case 146: - case 257: - case 260: + case 258: + case 261: case 149: case 148: case 151: case 152: - case 230: + case 231: return node.parent.name === node; case 178: return node.parent.argumentExpression === node; @@ -52422,17 +53044,17 @@ var ts; return undefined; } switch (node.kind) { - case 261: + case 262: case 149: case 148: - case 225: + case 226: case 184: case 151: case 152: - case 226: case 227: - case 229: + case 228: case 230: + case 231: return node; } } @@ -52440,22 +53062,22 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261: + case 262: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230: + case 231: return ts.ScriptElementKind.moduleElement; - case 226: + case 227: case 197: return ts.ScriptElementKind.classElement; - case 227: return ts.ScriptElementKind.interfaceElement; - case 228: return ts.ScriptElementKind.typeElement; - case 229: return ts.ScriptElementKind.enumElement; - case 223: + case 228: return ts.ScriptElementKind.interfaceElement; + case 229: return ts.ScriptElementKind.typeElement; + case 230: return ts.ScriptElementKind.enumElement; + case 224: return getKindOfVariableDeclaration(node); case 174: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); case 185: - case 225: + case 226: case 184: return ts.ScriptElementKind.functionElement; case 151: return ts.ScriptElementKind.memberGetAccessorElement; @@ -52471,15 +53093,15 @@ var ts; case 153: return ts.ScriptElementKind.callSignatureElement; case 150: return ts.ScriptElementKind.constructorImplementationElement; case 143: return ts.ScriptElementKind.typeParameterElement; - case 260: return ts.ScriptElementKind.enumMemberElement; + case 261: return ts.ScriptElementKind.enumMemberElement; case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234: - case 239: - case 236: - case 243: + case 235: + case 240: case 237: + case 244: + case 238: return ts.ScriptElementKind.alias; - case 285: + case 286: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -52551,19 +53173,19 @@ var ts; return false; } switch (n.kind) { - case 226: case 227: - case 229: + case 228: + case 230: case 176: case 172: case 161: - case 204: - case 231: + case 205: case 232: - case 238: - case 242: + case 233: + case 239: + case 243: return nodeEndsWith(n, 17, sourceFile); - case 256: + case 257: return isCompletedNode(n.block, sourceFile); case 180: if (!n.arguments) { @@ -52579,7 +53201,7 @@ var ts; case 150: case 151: case 152: - case 225: + case 226: case 184: case 149: case 148: @@ -52593,14 +53215,14 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 230: + case 231: return n.body && isCompletedNode(n.body, sourceFile); - case 208: + case 209: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207: + case 208: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); case 175: @@ -52614,15 +53236,15 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 253: case 254: + case 255: return false; - case 211: case 212: case 213: - case 210: + case 214: + case 211: return isCompletedNode(n.statement, sourceFile); - case 209: + case 210: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); @@ -52642,10 +53264,10 @@ var ts; case 194: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202: + case 203: return ts.nodeIsPresent(n.literal); - case 241: - case 235: + case 242: + case 236: return ts.nodeIsPresent(n.moduleSpecifier); case 190: return isCompletedNode(n.operand, sourceFile); @@ -52694,7 +53316,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 292 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 293 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -52749,8 +53371,8 @@ var ts; } } } - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; if (ts.isJSDocNode(child)) { continue; } @@ -52814,7 +53436,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); @@ -52829,7 +53451,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261); + ts.Debug.assert(startNode !== undefined || n.kind === 262); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -52874,13 +53496,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 252) { + if (token.kind === 26 && token.parent.kind === 253) { return true; } - if (token && token.kind === 17 && token.parent.kind === 252) { + if (token && token.kind === 17 && token.parent.kind === 253) { return true; } - if (token.kind === 26 && token.parent.kind === 249) { + if (token.kind === 26 && token.parent.kind === 250) { return true; } return false; @@ -52974,7 +53596,7 @@ var ts; if (node.kind === 157 || node.kind === 179) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 || node.kind === 227) { + if (ts.isFunctionLike(node) || node.kind === 227 || node.kind === 228) { return node.typeParameters; } return undefined; @@ -53047,11 +53669,11 @@ var ts; node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 213 && + if (node.parent.kind === 214 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 ? node.parent.parent : node.parent)) { return true; } } @@ -53268,7 +53890,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 || location.parent.kind === 243) && + (location.parent.kind === 240 || location.parent.kind === 244) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -53325,6 +53947,10 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -53373,15 +53999,15 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205: + case 206: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223: + case 224: case 147: case 146: return spanInVariableDeclaration(node); case 144: return spanInParameterDeclaration(node); - case 225: + case 226: case 149: case 148: case 151: @@ -53390,72 +54016,72 @@ var ts; case 184: case 185: return spanInFunctionDeclaration(node); - case 204: + case 205: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 231: + case 232: return spanInBlock(node); - case 256: + case 257: return spanInBlock(node.block); - case 207: - return textSpan(node.expression); - case 216: - return textSpan(node.getChildAt(0), node.expression); - case 210: - return textSpanEndingAtNextToken(node, node.expression); - case 209: - return spanInNode(node.statement); - case 222: - return textSpan(node.getChildAt(0)); case 208: - return textSpanEndingAtNextToken(node, node.expression); - case 219: - return spanInNode(node.statement); - case 215: - case 214: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 217: + return textSpan(node.getChildAt(0), node.expression); case 211: - return spanInForStatement(node); - case 212: return textSpanEndingAtNextToken(node, node.expression); - case 213: - return spanInInitializerOfForLike(node); - case 218: + case 210: + return spanInNode(node.statement); + case 223: + return textSpan(node.getChildAt(0)); + case 209: return textSpanEndingAtNextToken(node, node.expression); - case 253: - case 254: - return spanInNode(node.statements[0]); - case 221: - return spanInBlock(node.tryBlock); case 220: + return spanInNode(node.statement); + case 216: + case 215: + return textSpan(node.getChildAt(0), node.label); + case 212: + return spanInForStatement(node); + case 213: + return textSpanEndingAtNextToken(node, node.expression); + case 214: + return spanInInitializerOfForLike(node); + case 219: + return textSpanEndingAtNextToken(node, node.expression); + case 254: + case 255: + return spanInNode(node.statements[0]); + case 222: + return spanInBlock(node.tryBlock); + case 221: return textSpan(node, node.expression); - case 240: - return textSpan(node, node.expression); - case 234: - return textSpan(node, node.moduleReference); - case 235: - return textSpan(node, node.moduleSpecifier); case 241: + return textSpan(node, node.expression); + case 235: + return textSpan(node, node.moduleReference); + case 236: return textSpan(node, node.moduleSpecifier); - case 230: + case 242: + return textSpan(node, node.moduleSpecifier); + case 231: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 226: - case 229: - case 260: + case 227: + case 230: + case 261: case 174: return textSpan(node); - case 217: + case 218: return spanInNode(node.statement); case 145: return spanInNodeArray(node.parent.decorators); case 172: case 173: return spanInBindingPattern(node); - case 227: case 228: + case 229: return undefined; case 24: case 1: @@ -53491,8 +54117,8 @@ var ts; } if ((node.kind === 70 || node.kind == 196 || - node.kind === 257 || - node.kind === 258) && + node.kind === 258 || + node.kind === 259) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } @@ -53511,12 +54137,12 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209: + case 210: return spanInPreviousNode(node); case 145: return spanInNode(node.parent); - case 211: - case 213: + case 212: + case 214: return textSpan(node); case 192: if (node.parent.operatorToken.kind === 25) { @@ -53530,7 +54156,7 @@ var ts; break; } } - if (node.parent.kind === 257 && + if (node.parent.kind === 258 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); @@ -53541,7 +54167,7 @@ var ts; if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 223 || + if ((node.parent.kind === 224 || node.parent.kind === 144)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || @@ -53571,7 +54197,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 212) { + if (variableDeclaration.parent.parent.kind === 213) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -53579,7 +54205,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 213) { + variableDeclaration.parent.parent.kind === 214) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -53611,7 +54237,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 226 && functionDeclaration.kind !== 150); + (functionDeclaration.parent.kind === 227 && functionDeclaration.kind !== 150); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -53631,22 +54257,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230: + case 231: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 210: - case 208: - case 212: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 211: + case 209: case 213: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 212: + case 214: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224) { + if (forLikeStatement.initializer.kind === 225) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -53690,33 +54316,33 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229: + case 230: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226: + case 227: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232: + case 233: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231: + case 232: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 229: - case 226: + case 230: + case 227: return textSpan(node); - case 204: + case 205: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 256: + case 257: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232: + case 233: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -53748,7 +54374,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 || + if (node.parent.kind === 210 || node.parent.kind === 179 || node.parent.kind === 180) { return spanInPreviousNode(node); @@ -53761,17 +54387,17 @@ var ts; function spanInCloseParenToken(node) { switch (node.parent.kind) { case 184: - case 225: + case 226: case 185: case 149: case 148: case 151: case 152: case 150: - case 210: - case 209: case 211: - case 213: + case 210: + case 212: + case 214: case 179: case 180: case 183: @@ -53782,7 +54408,7 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 || + node.parent.kind === 258 || node.parent.kind === 144) { return spanInPreviousNode(node); } @@ -53795,13 +54421,13 @@ var ts; return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 210) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213) { + if (node.parent.kind === 214) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -53845,7 +54471,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -54152,10 +54778,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 230: - case 226: + case 231: case 227: - case 225: + case 228: + case 226: cancellationToken.throwIfCancellationRequested(); } } @@ -54199,7 +54825,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 && + return declaration.kind === 231 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -54256,7 +54882,7 @@ var ts; ts.Debug.assert(classifications.spans.length % 3 === 0); var dense = classifications.spans; var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -54340,16 +54966,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 281: + case 282: processJSDocParameterTag(tag); break; - case 284: + case 285: processJSDocTemplateTag(tag); break; - case 283: + case 284: processElement(tag.typeExpression); break; - case 282: + case 283: processElement(tag.typeExpression); break; } @@ -54430,22 +55056,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248: + case 249: if (token.parent.tagName === token) { return 19; } break; - case 249: + case 250: if (token.parent.tagName === token) { return 20; } break; - case 247: + case 248: if (token.parent.tagName === token) { return 21; } break; - case 250: + case 251: if (token.parent.name === token) { return 22; } @@ -54465,10 +55091,10 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 223 || + if (token.parent.kind === 224 || token.parent.kind === 147 || token.parent.kind === 144 || - token.parent.kind === 250) { + token.parent.kind === 251) { return 5; } } @@ -54485,7 +55111,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 250 ? 24 : 6; + return token.parent.kind === 251 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -54499,7 +55125,7 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 226: + case 227: if (token.parent.name === token) { return 11; } @@ -54509,17 +55135,17 @@ var ts; return 15; } return; - case 227: + case 228: if (token.parent.name === token) { return 13; } return; - case 229: + case 230: if (token.parent.name === token) { return 12; } return; - case 230: + case 231: if (token.parent.name === token) { return 14; } @@ -54540,9 +55166,8 @@ var ts; } if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { processElement(child); } @@ -54579,7 +55204,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 249) { + location.parent && location.parent.kind === 250) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -54601,13 +55226,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_45 in nameTable) { - if (nameTable[name_45] === position) { + for (var name_46 in nameTable) { + if (nameTable[name_46] === position) { continue; } - if (!uniqueNames[name_45]) { - uniqueNames[name_45] = name_45; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); + if (!uniqueNames[name_46]) { + uniqueNames[name_46] = name_46; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -54657,7 +55282,7 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 257 && + if (node.parent.kind === 258 && node.parent.parent.kind === 176 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); @@ -54665,7 +55290,7 @@ var ts; else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 235 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 236 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { @@ -54725,6 +55350,9 @@ var ts; return undefined; } function addStringLiteralCompletionsFromType(type, result) { + if (type && type.flags & 16384) { + type = typeChecker.getApparentType(type); + } if (!type) { return; } @@ -55029,11 +55657,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_13; + currentDir = parent_14; } else { break; @@ -55165,9 +55793,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283: - case 281: + case 284: case 282: + case 283: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -55202,13 +55830,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_14.kind === 177) { + if (parent_15.kind === 177) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141) { + else if (parent_15.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -55221,7 +55849,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 && contextToken.parent.kind === 249) { + else if (kind === 40 && contextToken.parent.kind === 250) { isStartingCloseTag = true; location = contextToken; } @@ -55312,7 +55940,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247) || (jsxContainer.kind === 248)) { + if ((jsxContainer.kind === 248) || (jsxContainer.kind === 249)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -55333,9 +55961,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 || + scopeNode.kind === 262 || scopeNode.kind === 194 || - scopeNode.kind === 252 || + scopeNode.kind === 253 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -55363,11 +55991,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 248) { + if (contextToken.parent.kind === 249) { return true; } - if (contextToken.parent.kind === 249 || contextToken.parent.kind === 247) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246; + if (contextToken.parent.kind === 250 || contextToken.parent.kind === 248) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 247; } } return false; @@ -55397,16 +56025,16 @@ var ts; case 128: return true; case 22: - return containingNodeKind === 230; + return containingNodeKind === 231; case 16: - return containingNodeKind === 226; + return containingNodeKind === 227; case 57: - return containingNodeKind === 223 + return containingNodeKind === 224 || containingNodeKind === 192; case 13: return containingNodeKind === 194; case 14: - return containingNodeKind === 202; + return containingNodeKind === 203; case 113: case 111: case 112: @@ -55482,9 +56110,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 ? - 235 : - 241; + var declarationKind = namedImportsOrExports.kind === 239 ? + 236 : + 242; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -55505,9 +56133,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 || parent_15.kind === 172)) { - return parent_15; + var parent_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { + return parent_16; } break; } @@ -55520,8 +56148,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 238: - case 242: + case 239: + case 243: return contextToken.parent; } } @@ -55530,34 +56158,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent_17 = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 250: case 251: - if (parent_16 && (parent_16.kind === 247 || parent_16.kind === 248)) { - return parent_16; + case 252: + if (parent_17 && (parent_17.kind === 248 || parent_17.kind === 249)) { + return parent_17; } - else if (parent_16.kind === 250) { - return parent_16.parent; + else if (parent_17.kind === 251) { + return parent_17.parent; } break; case 9: - if (parent_16 && ((parent_16.kind === 250) || (parent_16.kind === 251))) { - return parent_16.parent; + if (parent_17 && ((parent_17.kind === 251) || (parent_17.kind === 252))) { + return parent_17.parent; } break; case 17: - if (parent_16 && - parent_16.kind === 252 && - parent_16.parent && - (parent_16.parent.kind === 250)) { - return parent_16.parent.parent; + if (parent_17 && + parent_17.kind === 253 && + parent_17.parent && + (parent_17.parent.kind === 251)) { + return parent_17.parent.parent; } - if (parent_16 && parent_16.kind === 251) { - return parent_16.parent; + if (parent_17 && parent_17.kind === 252) { + return parent_17.parent; } break; } @@ -55568,7 +56196,7 @@ var ts; switch (kind) { case 184: case 185: - case 225: + case 226: case 149: case 148: case 151: @@ -55584,16 +56212,16 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 223 || - containingNodeKind === 224 || - containingNodeKind === 205 || - containingNodeKind === 229 || + return containingNodeKind === 224 || + containingNodeKind === 225 || + containingNodeKind === 206 || + containingNodeKind === 230 || isFunction(containingNodeKind) || - containingNodeKind === 226 || - containingNodeKind === 197 || containingNodeKind === 227 || + containingNodeKind === 197 || + containingNodeKind === 228 || containingNodeKind === 173 || - containingNodeKind === 228; + containingNodeKind === 229; case 22: return containingNodeKind === 173; case 55: @@ -55601,22 +56229,22 @@ var ts; case 20: return containingNodeKind === 173; case 18: - return containingNodeKind === 256 || + return containingNodeKind === 257 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 229 || - containingNodeKind === 227 || + return containingNodeKind === 230 || + containingNodeKind === 228 || containingNodeKind === 161; case 24: return containingNodeKind === 146 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 || + (contextToken.parent.parent.kind === 228 || contextToken.parent.parent.kind === 161); case 26: - return containingNodeKind === 226 || + return containingNodeKind === 227 || containingNodeKind === 197 || - containingNodeKind === 227 || containingNodeKind === 228 || + containingNodeKind === 229 || isFunction(containingNodeKind); case 114: return containingNodeKind === 147; @@ -55629,9 +56257,9 @@ var ts; case 112: return containingNodeKind === 144; case 117: - return containingNodeKind === 239 || - containingNodeKind === 243 || - containingNodeKind === 237; + return containingNodeKind === 240 || + containingNodeKind === 244 || + containingNodeKind === 238; case 74: case 82: case 108: @@ -55680,8 +56308,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_46 = element.propertyName || element.name; - existingImportsOrExports[name_46.text] = true; + var name_47 = element.propertyName || element.name; + existingImportsOrExports[name_47.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -55695,8 +56323,8 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 257 && - m.kind !== 258 && + if (m.kind !== 258 && + m.kind !== 259 && m.kind !== 174 && m.kind !== 149 && m.kind !== 151 && @@ -55726,7 +56354,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250) { + if (attr.kind === 251) { seenNames[attr.name.text] = true; } } @@ -55875,58 +56503,58 @@ var ts; switch (node.kind) { case 89: case 81: - if (hasKind(node.parent, 208)) { + if (hasKind(node.parent, 209)) { return getIfElseOccurrences(node.parent); } break; case 95: - if (hasKind(node.parent, 216)) { + if (hasKind(node.parent, 217)) { return getReturnOccurrences(node.parent); } break; case 99: - if (hasKind(node.parent, 220)) { + if (hasKind(node.parent, 221)) { return getThrowOccurrences(node.parent); } break; case 73: - if (hasKind(parent(parent(node)), 221)) { + if (hasKind(parent(parent(node)), 222)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101: case 86: - if (hasKind(parent(node), 221)) { + if (hasKind(parent(node), 222)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97: - if (hasKind(node.parent, 218)) { + if (hasKind(node.parent, 219)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72: case 78: - if (hasKind(parent(parent(parent(node))), 218)) { + if (hasKind(parent(parent(parent(node))), 219)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71: case 76: - if (hasKind(node.parent, 215) || hasKind(node.parent, 214)) { + if (hasKind(node.parent, 216) || hasKind(node.parent, 215)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87: - if (hasKind(node.parent, 211) || - hasKind(node.parent, 212) || - hasKind(node.parent, 213)) { + if (hasKind(node.parent, 212) || + hasKind(node.parent, 213) || + hasKind(node.parent, 214)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105: case 80: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { + if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -55943,7 +56571,7 @@ var ts; break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 206)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -55955,10 +56583,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 220) { + if (node.kind === 221) { statementAccumulator.push(node); } - else if (node.kind === 221) { + else if (node.kind === 222) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -55978,17 +56606,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261) { - return parent_17; + var parent_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262) { + return parent_18; } - if (parent_17.kind === 221) { - var tryStatement = parent_17; + if (parent_18.kind === 222) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_17; + child = parent_18; } return undefined; } @@ -55997,7 +56625,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 || node.kind === 214) { + if (node.kind === 216 || node.kind === 215) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -56010,23 +56638,23 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 218: - if (statement.kind === 214) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 219: + if (statement.kind === 215) { continue; } - case 211: case 212: case 213: + case 214: + case 211: case 210: - case 209: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -56037,24 +56665,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 226 || + if (!(container.kind === 227 || container.kind === 197 || (declaration.kind === 144 && hasKind(container, 150)))) { return undefined; } } else if (modifier === 114) { - if (!(container.kind === 226 || container.kind === 197)) { + if (!(container.kind === 227 || container.kind === 197)) { return undefined; } } else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 231 || container.kind === 261)) { + if (!(container.kind === 232 || container.kind === 262)) { return undefined; } } else if (modifier === 116) { - if (!(container.kind === 226 || declaration.kind === 226)) { + if (!(container.kind === 227 || declaration.kind === 227)) { return undefined; } } @@ -56065,8 +56693,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 231: - case 261: + case 232: + case 262: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -56077,7 +56705,7 @@ var ts; case 150: nodes = container.parameters.concat(container.parent.members); break; - case 226: + case 227: case 197: nodes = container.members; if (modifierFlag & 28) { @@ -56158,7 +56786,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 209) { + if (loopNode.kind === 210) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105)) { @@ -56179,13 +56807,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 211: case 212: case 213: - case 209: + case 214: case 210: + case 211: return getLoopBreakContinueOccurrences(owner); - case 218: + case 219: return getSwitchCaseDefaultOccurrences(owner); } } @@ -56235,7 +56863,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 204))) { + if (!(func && hasKind(func.body, 205))) { return undefined; } var keywords = []; @@ -56249,7 +56877,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 208) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 209) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -56260,7 +56888,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 208)) { + if (!hasKind(ifStatement.elseStatement, 209)) { break; } ifStatement = ifStatement.elseStatement; @@ -56295,7 +56923,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 220; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -56499,16 +57127,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 236); + var defaultImport = ts.getDeclarationOfKind(symbol, 237); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 || - declaration.kind === 243) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 || + declaration.kind === 244) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 239 ? + return importOrExportSpecifier.kind === 240 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -56552,7 +57180,7 @@ var ts; if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226); + return ts.getAncestor(privateDeclaration, 227); } } if (symbol.flags & 8388608) { @@ -56576,7 +57204,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 261 && !ts.isExternalModule(container)) { + if (container.kind === 262 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -56813,7 +57441,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70) { - if (refNode.parent.kind === 258) { + if (refNode.parent.kind === 259) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -56823,24 +57451,24 @@ var ts; } var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); + var parent_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 205) { + ts.forEachReturnStatement(parent_19.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); + else if (isImplementationExpression(parent_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -56876,7 +57504,7 @@ var ts; function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { if (node.kind === 199 - && node.parent.kind === 255 + && node.parent.kind === 256 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -56923,7 +57551,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 227) { + else if (declaration.kind === 228) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -56997,11 +57625,11 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; - case 261: + case 262: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 225: + case 226: case 184: break; default: @@ -57009,7 +57637,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 261) { + if (searchSpaceNode.kind === 262) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -57044,7 +57672,7 @@ var ts; var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { case 184: - case 225: + case 226: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } @@ -57056,13 +57684,13 @@ var ts; } break; case 197: - case 226: + case 227: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 261: - if (container.kind === 261 && !ts.isExternalModule(container)) { + case 262: + if (container.kind === 262 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -57097,13 +57725,13 @@ var ts; for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { var position = possiblePositions_1[_i]; cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9) { + var node_3 = ts.getTouchingWord(sourceFile, position); + if (!node_3 || node_3.kind !== 9) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + references.push(getReferenceEntryFromNode(node_3)); } } } @@ -57111,7 +57739,7 @@ var ts; function populateSearchSymbolSet(symbol, location) { var result = [symbol]; var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -57161,7 +57789,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 227) { + else if (declaration.kind === 228) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -57293,7 +57921,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223) { + else if (node.kind === 224) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -57303,18 +57931,18 @@ var ts; } else { switch (node.kind) { - case 226: + case 227: case 197: - case 229: case 230: + case 231: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205) { - ts.Debug.assert(node.parent.kind === 224); + if (node.parent && node.parent.parent && node.parent.parent.kind === 206) { + ts.Debug.assert(node.parent.kind === 225); return node.parent.parent; } } @@ -57384,8 +58012,8 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 257: case 258: + case 259: case 149: case 151: case 152: @@ -57447,11 +58075,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 239 && declaration.parent && declaration.parent.kind === 238))) { + (declaration.kind === 240 && declaration.parent && declaration.parent.kind === 239))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 258) { + if (node.parent.kind === 259) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -57529,7 +58157,7 @@ var ts; var definition; ts.forEach(signatureDeclarations, function (d) { if ((selectConstructors && d.kind === 150) || - (!selectConstructors && (d.kind === 225 || d.kind === 149 || d.kind === 148))) { + (!selectConstructors && (d.kind === 226 || d.kind === 149 || d.kind === 148))) { declarations.push(d); if (d.body) definition = d; @@ -57605,7 +58233,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 258) { + if (node.parent.kind === 259) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -57697,7 +58325,7 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -57731,16 +58359,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225: + case 226: case 149: case 150: - case 226: - case 205: + case 227: + case 206: break findOwner; - case 261: + case 262: return undefined; - case 230: - if (commentOwner.parent.kind === 230) { + case 231: + if (commentOwner.parent.kind === 231) { return undefined; } break findOwner; @@ -57755,7 +58383,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 ? currentName.text : @@ -57780,7 +58408,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205) { + if (commentOwner.kind === 206) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -57823,10 +58451,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + for (var name_48 in nameToDeclarations) { + var declarations = nameToDeclarations[name_48]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); if (!matches) { continue; } @@ -57837,21 +58465,21 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name_48); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 || decl.kind === 239 || decl.kind === 234) { + if (decl.kind === 237 || decl.kind === 240 || decl.kind === 235) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -58076,14 +58704,14 @@ var ts; addLeafNode(node); } break; - case 236: + case 237: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 238) { addLeafNode(namedBindings); } else { @@ -58095,11 +58723,11 @@ var ts; } break; case 174: - case 223: + case 224: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name_49 = decl.name; + if (ts.isBindingPattern(name_49)) { + addChildrenRecursively(name_49); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -58109,11 +58737,11 @@ var ts; } break; case 185: - case 225: + case 226: case 184: addNodeWithRecursiveChild(node, node.body); break; - case 229: + case 230: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -58123,9 +58751,9 @@ var ts; } endNode(); break; - case 226: - case 197: case 227: + case 197: + case 228: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -58133,21 +58761,21 @@ var ts; } endNode(); break; - case 230: + case 231: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243: - case 234: + case 244: + case 235: case 155: case 153: case 154: - case 228: + case 229: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285) { + if (tag.kind === 286) { addLeafNode(tag); } }); @@ -58195,12 +58823,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 231 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230) { + if (a.body.kind !== 231) { return true; } return areSameModule(a.body, b.body); @@ -58251,7 +58879,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return getModuleName(node); } var decl = node; @@ -58263,14 +58891,14 @@ var ts; case 185: case 197: return getFunctionOrClassName(node); - case 285: + case 286: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return getModuleName(node); } var name = node.name; @@ -58281,15 +58909,15 @@ var ts; } } switch (node.kind) { - case 261: + case 262: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; case 185: - case 225: - case 184: case 226: + case 184: + case 227: case 197: if (ts.getModifierFlags(node) & 512) { return "default"; @@ -58303,7 +58931,7 @@ var ts; return "()"; case 155: return "[]"; - case 285: + case 286: return getJSDocTypedefTagName(node); default: return ""; @@ -58315,7 +58943,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 206) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -58343,23 +58971,23 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226: - case 197: - case 229: case 227: + case 197: case 230: - case 261: case 228: - case 285: + case 231: + case 262: + case 229: + case 286: return true; case 150: case 149: case 151: case 152: - case 223: + case 224: return hasSomeImportantChild(item); case 185: - case 225: + case 226: case 184: return isTopLevelFunctionDeclaration(item); default: @@ -58370,8 +58998,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231: - case 261: + case 232: + case 262: case 149: case 150: return true; @@ -58382,7 +59010,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 && childKind !== 174; + return childKind !== 224 && childKind !== 174; }); } } @@ -58437,20 +59065,20 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 230) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 231) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 230 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 231 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { return !member.name || member.name.kind === 142; } function getNodeSpan(node) { - return node.kind === 261 + return node.kind === 262 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -58458,14 +59086,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 224) { return ts.declarationNameToString(node.parent.name); } else if (node.parent.kind === 192 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 && node.parent.name) { + else if (node.parent.kind === 258 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -58561,26 +59189,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204: + case 205: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent_20 = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_19.kind === 209 || - parent_19.kind === 212 || - parent_19.kind === 213 || - parent_19.kind === 211 || - parent_19.kind === 208 || - parent_19.kind === 210 || - parent_19.kind === 217 || - parent_19.kind === 256) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent_20.kind === 210 || + parent_20.kind === 213 || + parent_20.kind === 214 || + parent_20.kind === 212 || + parent_20.kind === 209 || + parent_20.kind === 211 || + parent_20.kind === 218 || + parent_20.kind === 257) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221) { - var tryStatement = parent_19; + if (parent_20.kind === 222) { + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -58600,17 +59228,17 @@ var ts; }); break; } - case 231: { + case 232: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226: case 227: - case 229: + case 228: + case 230: case 176: - case 232: { + case 233: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); @@ -58878,7 +59506,8 @@ var ts; return str === str.toLowerCase(); } function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -58886,7 +59515,7 @@ var ts; return -1; } function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -58954,7 +59583,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -59527,7 +60156,7 @@ var ts; var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 && node.parent.parent.parent.kind === 181) { + else if (node.parent.kind === 203 && node.parent.parent.parent.kind === 181) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; @@ -59604,7 +60233,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261; n = n.parent) { + for (var n = node; n.kind !== 262; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -59966,7 +60595,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230); + var declaration = ts.getDeclarationOfKind(symbol, 231); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); @@ -60001,7 +60630,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 228) { + else if (declaration.kind === 229) { addInPrefix(); displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); @@ -60014,7 +60643,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260) { + if (declaration.kind === 261) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -60026,7 +60655,7 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233) { + if (symbol.declarations[0].kind === 234) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128)); @@ -60037,7 +60666,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234) { + if (declaration.kind === 235) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -60105,7 +60734,7 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 192) { @@ -60191,11 +60820,11 @@ var ts; if (declaration.kind === 184) { return true; } - if (declaration.kind !== 223 && declaration.kind !== 225) { + if (declaration.kind !== 224 && declaration.kind !== 226) { return false; } - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { - if (parent_20.kind === 261 || parent_20.kind === 231) { + for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { + if (parent_21.kind === 262 || parent_21.kind === 232) { return false; } } @@ -60386,10 +61015,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 251: + case 249: case 250: case 248: - case 249: - case 247: return node.kind === 70; } } @@ -60722,10 +61351,10 @@ var ts; this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 140, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([19, 21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60736,10 +61365,10 @@ var ts; this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); @@ -60759,6 +61388,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109, 75]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60767,9 +61397,10 @@ var ts; this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 133, 114, 136, 138]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 133, 114, 136, 138, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -60797,6 +61428,7 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -60825,7 +61457,7 @@ var ts; this.NoSpaceBetweenTagAndTemplateString, this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -60840,6 +61472,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; this.LowPriorityCommonRules = [ this.NoSpaceBeforeSemicolon, @@ -60848,7 +61481,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); @@ -60889,15 +61521,15 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name_50 in o) { + if (o[name_50] === rule) { + return name_50; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 211; + return context.contextNode.kind === 212; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); @@ -60907,24 +61539,25 @@ var ts; case 192: case 193: case 200: - case 243: - case 239: + case 244: + case 240: case 156: case 164: case 165: return true; case 174: - case 228: - case 234: - case 223: + case 229: + case 235: + case 224: case 144: - case 260: + case 261: case 147: case 146: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 212: - return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; case 213: + case 143: + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 214: return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; } return false; @@ -60938,6 +61571,9 @@ var ts; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 172 || Rules.IsSingleLineBlockContext(context); + }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); }; @@ -60958,17 +61594,17 @@ var ts; return true; } switch (node.kind) { - case 204: - case 232: + case 205: + case 233: case 176: - case 231: + case 232: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225: + case 226: case 149: case 148: case 151: @@ -60977,58 +61613,64 @@ var ts; case 184: case 150: case 185: - case 227: + case 228: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 || context.contextNode.kind === 184; + return context.contextNode.kind === 226 || context.contextNode.kind === 184; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226: - case 197: case 227: - case 229: - case 161: + case 197: + case 228: case 230: - case 241: + case 161: + case 231: case 242: - case 235: - case 238: + case 243: + case 236: + case 239: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226: - case 230: - case 229: - case 204: - case 256: + case 227: case 231: - case 218: + case 230: + case 257: + case 232: + case 219: return true; + case 205: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 185 && + blockParent.kind !== 184) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208: - case 218: - case 211: + case 209: + case 219: case 212: case 213: + case 214: + case 211: + case 222: case 210: - case 221: - case 209: - case 217: - case 256: + case 218: + case 257: return true; default: return false; @@ -61059,19 +61701,19 @@ var ts; return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246; + return context.contextNode.kind !== 247; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252; + return context.contextNode.kind === 253; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250; + return context.nextTokenParent.kind === 251; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250; + return context.contextNode.kind === 251; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247; + return context.contextNode.kind === 248; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -61089,14 +61731,14 @@ var ts; return node.kind === 145; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 && + return context.currentTokenParent.kind === 225 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230; + return context.contextNode.kind === 231; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 161; @@ -61108,10 +61750,11 @@ var ts; switch (parent.kind) { case 157: case 182: - case 226: - case 197: + case 229: case 227: - case 225: + case 197: + case 228: + case 226: case 184: case 185: case 149: @@ -61139,6 +61782,9 @@ var ts; Rules.IsYieldOrYieldStarWithOperand = function (context) { return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 201; + }; return Rules; }()); formatting.Rules = Rules; @@ -61423,6 +62069,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -61501,6 +62153,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -61598,17 +62256,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 226: case 227: + case 228: return ts.rangeContainsRange(parent.members, node); - case 230: - var body = parent.body; - return body && body.kind === 231 && ts.rangeContainsRange(body.statements, node); - case 261: - case 204: case 231: + var body = parent.body; + return body && body.kind === 232 && ts.rangeContainsRange(body.statements, node); + case 262: + case 205: + case 232: return ts.rangeContainsRange(parent.statements, node); - case 256: + case 257: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -61764,10 +62422,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226: return 74; - case 227: return 108; - case 225: return 88; - case 229: return 229; + case 227: return 74; + case 228: return 108; + case 226: return 88; + case 230: return 230; case 151: return 124; case 152: return 133; case 149: @@ -61799,17 +62457,30 @@ var ts; switch (kind) { case 16: case 17: - case 20: - case 21: case 18: case 19: case 81: case 105: case 56: return indentation; - default: - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40: + case 28: { + if (container.kind === 249 || + container.kind === 250 || + container.kind === 248) { + return indentation; + } + break; + } + case 20: + case 21: { + if (container.kind !== 170) { + return indentation; + } + break; + } } + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -61850,7 +62521,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -61880,7 +62551,7 @@ var ts; if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -61915,10 +62586,10 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -61931,7 +62602,7 @@ var ts; if (formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -62121,7 +62792,7 @@ var ts; startLine++; } var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -62212,7 +62883,7 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 150: - case 225: + case 226: case 184: case 149: case 148: @@ -62436,7 +63107,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 261 || !parentAndChildShareLine); + (parent.kind === 262 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -62460,7 +63131,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 && parent.elseStatement === child) { + if (parent.kind === 209 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -62482,7 +63153,7 @@ var ts; return node.parent.properties; case 175: return node.parent.elements; - case 225: + case 226: case 184: case 185: case 149: @@ -62604,35 +63275,36 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207: - case 226: - case 197: + case 208: case 227: - case 229: + case 197: case 228: + case 230: + case 229: case 175: - case 204: - case 231: + case 205: + case 232: case 176: case 161: + case 170: case 163: - case 232: + case 233: + case 255: case 254: - case 253: case 183: case 177: case 179: case 180: - case 205: - case 223: - case 240: - case 216: + case 206: + case 224: + case 241: + case 217: case 193: case 173: case 172: + case 249: case 248: - case 247: - case 252: + case 253: case 148: case 153: case 154: @@ -62642,10 +63314,10 @@ var ts; case 166: case 181: case 189: - case 242: - case 238: case 243: case 239: + case 244: + case 240: return true; } return false; @@ -62653,27 +63325,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 209: case 210: - case 212: - case 213: case 211: - case 208: - case 225: + case 213: + case 214: + case 212: + case 209: + case 226: case 184: case 149: case 185: case 150: case 151: case 152: - return childKind !== 204; - case 241: - return childKind !== 242; - case 235: - return childKind !== 236 || - (child.namedBindings && child.namedBindings.kind !== 238); - case 246: - return childKind !== 249; + return childKind !== 205; + case 242: + return childKind !== 243; + case 236: + return childKind !== 237 || + (child.namedBindings && child.namedBindings.kind !== 239); + case 247: + return childKind !== 250; } return indentByDefault; } @@ -62723,24 +63395,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_7 = writer.string(); + ts.releaseStringWriter(writer); + return result_7; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8) && !!(flags & 128); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -62762,7 +63530,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -62778,7 +63546,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 && ts.isSuperCall(n.expression)) { + if (n.kind === 208 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -62791,6 +63559,216 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind === 20) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70: + switch (token.parent.kind) { + case 224: + switch (token.parent.parent.parent.kind) { + case 212: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 214: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 225) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 213: + return undefined; + case 257: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + case 235: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 240: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + case 237: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 238: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 238: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 236 && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + 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); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -62876,7 +63854,10 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -62887,6 +63868,11 @@ var ts; var symbolIdActionMap = new ImportCodeActionMap(); var cachedImportDeclarations = ts.createMap(); var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, false, true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -62894,7 +63880,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -62931,10 +63916,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235) { + if (node.kind === 236) { return node; } - if (node.kind === 234) { + if (node.kind === 235) { return node; } node = node.parent; @@ -62952,7 +63937,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { return getCodeActionsForExistingImport(existingDeclarations); @@ -62967,9 +63952,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { var declaration = declarations_11[_i]; - if (declaration.kind === 235) { + if (declaration.kind === 236) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237) { + if (namedBindings && namedBindings.kind === 238) { namespaceImportDeclaration = declaration; } else { @@ -62985,7 +63970,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); @@ -62996,7 +63981,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245) { + if (declaration.moduleReference && declaration.moduleReference.kind === 246) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -63029,7 +64014,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235) { + if (declaration.kind === 236) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -63055,7 +64040,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; var newText = cachedNewImportInsertPosition === sourceFile.getStart() ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter : "" + context.newLineCharacter + importStatementText + ";"; @@ -63072,7 +64059,7 @@ var ts; tryGetModuleNameAsNodeModule() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261) { + if (moduleSymbol.valueDeclaration.kind !== 262) { return moduleSymbol.name; } } @@ -63085,6 +64072,7 @@ var ts; if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -63104,7 +64092,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -63223,144 +64211,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - if (token.kind === 20) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70: - switch (token.parent.kind) { - case 223: - switch (token.parent.parent.parent.kind) { - case 211: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212: - return undefined; - case 256: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - case 234: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - case 236: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 && importDecl.parent) { - importDecl = importDecl.parent; + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 151: + case 152: + case 146: + case 147: + var typeString = checker.typeToString(type, enclosingDeclaration, 0); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 148: + case 149: + var signatures = checker.getSignaturesOfType(type, 0); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(153); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(144); + newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4) { + return "public "; + } + else if (flags & 16) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; @@ -63425,7 +64389,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292, nodes.pos, nodes.end, this); + var list = createNode(293, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -63448,7 +64412,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 && this.kind <= 291; + var useJSDocScanner_1 = this.kind >= 279 && this.kind <= 292; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -63721,9 +64685,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_7 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_7 !== undefined) { - return result_7; + var result_8 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_8 !== undefined) { + return result_8; } if (declaration.name.kind === 142) { var expr = declaration.name.expression; @@ -63747,7 +64711,7 @@ var ts; } function visit(node) { switch (node.kind) { - case 225: + case 226: case 184: case 149: case 148: @@ -63767,18 +64731,18 @@ var ts; } ts.forEachChild(node, visit); break; - case 226: - case 197: case 227: + case 197: case 228: case 229: case 230: - case 234: - case 243: - case 239: - case 234: - case 236: + case 231: + case 235: + case 244: + case 240: + case 235: case 237: + case 238: case 151: case 152: case 161: @@ -63789,7 +64753,7 @@ var ts; if (!ts.hasModifier(node, 92)) { break; } - case 223: + case 224: case 174: { var decl = node; if (ts.isBindingPattern(decl.name)) { @@ -63799,24 +64763,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260: + case 261: case 147: case 146: addDeclaration(node); break; - case 241: + case 242: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 235: + case 236: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 238) { addDeclaration(importClause.namedBindings); } else { @@ -64411,7 +65375,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 230 && + if (nodeForStartPos.parent.parent.kind === 231 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -64600,7 +65564,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -64709,7 +65673,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 245 || + node.parent.kind === 246 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -65075,15 +66039,15 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_50 = names_2[_i]; - var resolution = newResolutions[name_50]; + var name_51 = names_2[_i]; + var resolution = newResolutions[name_51]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_50]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_51]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_50] = resolution = loader(name_50, containingFile, compilerOptions, this); + newResolutions[name_51] = resolution = loader(name_51, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -65123,6 +66087,9 @@ var ts; return resolution.failedLookupLocations.length === 0; } }; + LSHost.prototype.getNewLine = function () { + return this.host.newLine; + }; LSHost.prototype.getProjectVersion = function () { return this.project.getProjectVersion(); }; @@ -65328,7 +66295,7 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 230 || statement.name.kind !== 9) { + if (statement.kind !== 231 || statement.name.kind !== 9) { return false; } } @@ -65439,7 +66406,7 @@ var ts; var ModuleBuilderFileInfo = (function (_super) { __extends(ModuleBuilderFileInfo, _super); function ModuleBuilderFileInfo() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.references = []; _this.referencedBy = []; return _this; @@ -65802,7 +66769,7 @@ var ts; info.detachFromProject(this); } } - else { + if (!this.program || !this.languageServiceEnabled) { for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { var root = _c[_b]; root.detachFromProject(this); @@ -65948,9 +66915,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_51 in file.resolvedModules) { - if (!file.resolvedModules[name_51] && !ts.isExternalModuleNameRelative(name_51)) { - var trimmed = name_51.trim(); + for (var name_52 in file.resolvedModules) { + if (!file.resolvedModules[name_52] && !ts.isExternalModuleNameRelative(name_52)) { + var trimmed = name_52.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -68539,9 +69506,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_53 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -69022,7 +69989,7 @@ var ts; if (len > 1) { var insertedNodes = new Array(len - 1); var startNode = leafNode; - for (var i = 1, len_1 = lines.length; i < len_1; i++) { + for (var i = 1; i < lines.length; i++) { insertedNodes[i - 1] = new LineLeaf(lines[i]); } var pathIndex = this.startPath.length - 2; @@ -69219,8 +70186,8 @@ var ts; var snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { var snapIndex = snap.index; - for (var i = 0, len = this.changes.length; i < len; i++) { - var change = this.changes[i]; + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var change = _a[_i]; snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); } snap = new LineIndexSnapshot(this.currentVersion + 1, this); @@ -69241,8 +70208,8 @@ var ts; var textChangeRanges = []; for (var i = oldVersion + 1; i <= newVersion; i++) { var snap = this.versions[this.versionToIndex(i)]; - for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; + for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { + var textChange = _a[_i]; textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); } } @@ -69342,7 +70309,7 @@ var ts; LineIndex.prototype.load = function (lines) { if (lines.length > 0) { var leaves = []; - for (var i = 0, len = lines.length; i < len; i++) { + for (var i = 0; i < lines.length; i++) { leaves[i] = new LineLeaf(lines[i]); } this.root = LineIndex.buildTreeFromBottom(leaves); @@ -69502,8 +70469,8 @@ var ts; LineNode.prototype.updateCounts = function () { this.totalChars = 0; this.totalLines = 0; - for (var i = 0, len = this.children.length; i < len; i++) { - var child = this.children[i]; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; this.totalChars += child.charCount(); this.totalLines += child.lineCount(); } @@ -70464,7 +71431,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index c5cee20bdde..65a33f28c33 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -239,102 +239,102 @@ declare namespace ts { ExpressionWithTypeArguments = 199, AsExpression = 200, NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, + MetaProperty = 202, + TemplateSpan = 203, + SemicolonClassElement = 204, + Block = 205, + VariableStatement = 206, + EmptyStatement = 207, + ExpressionStatement = 208, + IfStatement = 209, + DoStatement = 210, + WhileStatement = 211, + ForStatement = 212, + ForInStatement = 213, + ForOfStatement = 214, + ContinueStatement = 215, + BreakStatement = 216, + ReturnStatement = 217, + WithStatement = 218, + SwitchStatement = 219, + LabeledStatement = 220, + ThrowStatement = 221, + TryStatement = 222, + DebuggerStatement = 223, + VariableDeclaration = 224, + VariableDeclarationList = 225, + FunctionDeclaration = 226, + ClassDeclaration = 227, + InterfaceDeclaration = 228, + TypeAliasDeclaration = 229, + EnumDeclaration = 230, + ModuleDeclaration = 231, + ModuleBlock = 232, + CaseBlock = 233, + NamespaceExportDeclaration = 234, + ImportEqualsDeclaration = 235, + ImportDeclaration = 236, + ImportClause = 237, + NamespaceImport = 238, + NamedImports = 239, + ImportSpecifier = 240, + ExportAssignment = 241, + ExportDeclaration = 242, + NamedExports = 243, + ExportSpecifier = 244, + MissingDeclaration = 245, + ExternalModuleReference = 246, + JsxElement = 247, + JsxSelfClosingElement = 248, + JsxOpeningElement = 249, + JsxClosingElement = 250, + JsxAttribute = 251, + JsxSpreadAttribute = 252, + JsxExpression = 253, + CaseClause = 254, + DefaultClause = 255, + HeritageClause = 256, + CatchClause = 257, + PropertyAssignment = 258, + ShorthandPropertyAssignment = 259, + SpreadAssignment = 260, + EnumMember = 261, + SourceFile = 262, + JSDocTypeExpression = 263, + JSDocAllType = 264, + JSDocUnknownType = 265, + JSDocArrayType = 266, + JSDocUnionType = 267, + JSDocTupleType = 268, + JSDocNullableType = 269, + JSDocNonNullableType = 270, + JSDocRecordType = 271, + JSDocRecordMember = 272, + JSDocTypeReference = 273, + JSDocOptionalType = 274, + JSDocFunctionType = 275, + JSDocVariadicType = 276, + JSDocConstructorType = 277, + JSDocThisType = 278, + JSDocComment = 279, + JSDocTag = 280, + JSDocAugmentsTag = 281, + JSDocParameterTag = 282, + JSDocReturnTag = 283, + JSDocTypeTag = 284, + JSDocTemplateTag = 285, + JSDocTypedefTag = 286, + JSDocPropertyTag = 287, + JSDocTypeLiteral = 288, + JSDocLiteralType = 289, + JSDocNullKeyword = 290, + JSDocUndefinedKeyword = 291, + JSDocNeverKeyword = 292, + SyntaxList = 293, + NotEmittedStatement = 294, + PartiallyEmittedExpression = 295, + MergeDeclarationMarker = 296, + EndOfDeclarationMarker = 297, Count = 298, FirstAssignment = 57, LastAssignment = 69, @@ -361,10 +361,10 @@ declare namespace ts { FirstBinaryOperator = 26, LastBinaryOperator = 69, FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstJSDocNode = 263, + LastJSDocNode = 289, + FirstJSDocTagNode = 279, + LastJSDocTagNode = 292, } enum NodeFlags { None = 0, @@ -969,6 +969,11 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; @@ -1003,6 +1008,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1022,7 +1028,7 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; @@ -1569,6 +1575,7 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): ObjectType[]; @@ -1581,6 +1588,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -1603,11 +1612,13 @@ declare namespace ts { isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; + getApparentType(type: Type): Type; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1645,6 +1656,7 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, } enum SymbolFormatFlags { None = 0, @@ -1815,6 +1827,7 @@ declare namespace ts { interface ObjectType extends Type { objectFlags: ObjectFlags; } + /** Class and interface types (TypeFlags.Class and TypeFlags.Interface). */ interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; @@ -1828,6 +1841,16 @@ declare namespace ts { declaredStringIndexInfo: IndexInfo; declaredNumberIndexInfo: IndexInfo; } + /** + * Type references (TypeFlags.Reference). When a class or interface has type parameters or + * a "this" type, references to the class or interface are made using type references. The + * typeArguments property specifies the types to substitute for the type parameters of the + * class or interface and optionally includes an extra element that specifies the type to + * substitute for "this" in the resulting instantiation. When no extra argument is present, + * the type reference itself is substituted for "this". The typeArguments property is undefined + * if the class or interface has no type parameters and the reference isn't specifying an + * explicit "this" argument. + */ interface TypeReference extends ObjectType { target: GenericType; typeArguments: Type[]; @@ -2106,7 +2129,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -2325,9 +2347,28 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + /** + * Cached module resolutions per containing directory. + * This assumes that any module id will have the same resolution for sibling files located in the same folder. + */ + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; + } + /** + * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory + * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. + */ + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + } + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; + } + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; @@ -2674,6 +2715,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -2682,6 +2724,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -2689,6 +2732,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -2697,6 +2741,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } diff --git a/lib/typescript.js b/lib/typescript.js index 7f41e5d07f5..bae2811e4de 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword @@ -244,115 +249,115 @@ var ts; SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 202] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 202] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 203] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 203] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 204] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 204] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 205] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 206] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 207] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 208] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 209] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 210] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 211] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 212] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 213] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 214] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 215] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 216] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 217] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 218] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 219] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 220] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 221] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 222] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 224] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 225] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 226] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 227] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 228] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 229] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 230] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 231] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 232] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 233] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 234] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 235] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 236] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 237] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 238] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 239] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 240] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 241] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 242] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 243] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 244] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 205] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 206] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 207] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 208] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 209] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 210] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 211] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 212] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 213] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 214] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 215] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 216] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 217] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 218] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 219] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 220] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 221] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 222] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 223] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 225] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 226] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 227] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 228] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 229] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 230] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 231] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 232] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 233] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 234] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 235] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 236] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 237] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 238] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 239] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 240] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 241] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 242] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 243] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 244] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 245] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 246] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 246] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 247] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 248] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 249] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 250] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 251] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 252] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 247] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 248] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 249] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 250] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 251] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 252] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 253] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 253] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 254] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 255] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 256] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 254] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 255] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 256] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 257] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 257] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 258] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 259] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 258] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 259] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 260] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 260] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 261] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 261] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 262] = "SourceFile"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 262] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 263] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 263] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 264] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 264] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 265] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 266] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 267] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 268] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 269] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 270] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 271] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 272] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 273] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 274] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 275] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 276] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 277] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 278] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 279] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 280] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 281] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 282] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 283] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 284] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 285] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 286] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 288] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 289] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 290] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 291] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 265] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 266] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 267] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 268] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 269] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 270] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 271] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 272] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 273] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 274] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 275] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 276] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 277] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 278] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 279] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 280] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 281] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 282] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 283] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 284] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 285] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 286] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 287] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 288] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 289] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 290] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 291] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 292] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 292] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 293] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 293] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 294] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 295] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 296] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["RawExpression"] = 297] = "RawExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 294] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 295] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 296] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 297] = "EndOfDeclarationMarker"; // Enum value count SyntaxKind[SyntaxKind["Count"] = 298] = "Count"; // Markers @@ -381,10 +386,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 262] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 288] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 278] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 291] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 263] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 289] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 279] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 292] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -511,6 +516,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -647,6 +653,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; @@ -1290,7 +1297,7 @@ var ts; */ function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1314,7 +1321,7 @@ var ts; */ function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -1325,7 +1332,7 @@ var ts; ts.every = every; /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -1339,7 +1346,7 @@ var ts; * This is like `forEach`, but never returns undefined. */ function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1362,7 +1369,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -1372,7 +1379,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -2220,6 +2227,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -3915,7 +3923,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -4072,6 +4080,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -4301,6 +4310,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -4310,6 +4321,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -4361,6 +4373,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -4529,6 +4543,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -4542,10 +4557,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -4594,6 +4609,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -4650,22 +4667,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); /// @@ -5132,7 +5152,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -5344,7 +5364,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -6524,7 +6544,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261 /* SourceFile */) { + while (node && node.kind !== 262 /* SourceFile */) { node = node.parent; } return node; @@ -6532,11 +6552,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 205 /* Block */: + case 233 /* CaseBlock */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return true; } return false; @@ -6627,18 +6647,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 292 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 293 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 /* FirstJSDocNode */ && node.kind <= 288 /* LastJSDocNode */; + return node.kind >= 263 /* FirstJSDocNode */ && node.kind <= 289 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 /* FirstJSDocTagNode */ && node.kind <= 291 /* LastJSDocTagNode */; + return node.kind >= 279 /* FirstJSDocTagNode */ && node.kind <= 292 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6742,11 +6762,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 /* VariableDeclaration */ && node.parent.kind === 256 /* CatchClause */; + return node.kind === 224 /* VariableDeclaration */ && node.parent.kind === 257 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 /* ModuleDeclaration */ && + return node && node.kind === 231 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6757,11 +6777,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 230 /* ModuleDeclaration */ && (!node.body); + return node.kind === 231 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 /* SourceFile */ || - node.kind === 230 /* ModuleDeclaration */ || + return node.kind === 262 /* SourceFile */ || + node.kind === 231 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6777,9 +6797,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.isExternalModule(node.parent); - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6791,22 +6811,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 256 /* CatchClause */: - case 230 /* ModuleDeclaration */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 262 /* SourceFile */: + case 233 /* CaseBlock */: + case 257 /* CatchClause */: + case 231 /* ModuleDeclaration */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: case 150 /* Constructor */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return true; - case 204 /* Block */: + case 205 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6891,7 +6911,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204 /* Block */) { + if (node.body && node.body.kind === 205 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6905,7 +6925,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -6914,20 +6934,20 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 225 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: errorNode = node.name; break; case 185 /* ArrowFunction */: @@ -6953,7 +6973,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 /* EnumDeclaration */ && isConst(node); + return node.kind === 230 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6970,7 +6990,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 /* ExpressionStatement */ + return node.kind === 208 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -7053,9 +7073,9 @@ var ts; case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 144 /* Parameter */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return node === parent_1.type; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 150 /* Constructor */: @@ -7081,29 +7101,43 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190 /* PrefixUnaryExpression */; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // Warning: This has the same semantics as the forEach family of functions, // in that traversal terminates in the event that 'visitor' supplies a truthy value. function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitor(node); - case 232 /* CaseBlock */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 254 /* DefaultClause */: - case 219 /* LabeledStatement */: - case 221 /* TryStatement */: - case 256 /* CatchClause */: + case 233 /* CaseBlock */: + case 205 /* Block */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 218 /* WithStatement */: + case 219 /* SwitchStatement */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: + case 220 /* LabeledStatement */: + case 222 /* TryStatement */: + case 257 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7119,11 +7153,11 @@ var ts; if (operand) { traverse(operand); } - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 226 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be @@ -7170,13 +7204,13 @@ var ts; if (node) { switch (node.kind) { case 174 /* BindingElement */: - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 144 /* Parameter */: - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 258 /* ShorthandPropertyAssignment */: - case 223 /* VariableDeclaration */: + case 259 /* ShorthandPropertyAssignment */: + case 224 /* VariableDeclaration */: return true; } } @@ -7188,7 +7222,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); + return node && (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7199,7 +7233,7 @@ var ts; switch (kind) { case 150 /* Constructor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -7222,7 +7256,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return true; } @@ -7231,20 +7265,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: return true; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220 /* LabeledStatement */) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 205 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -7323,9 +7369,9 @@ var ts; continue; } // Fall through - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 149 /* MethodDeclaration */: @@ -7336,13 +7382,26 @@ var ts; case 153 /* CallSignature */: case 154 /* ConstructSignature */: case 155 /* IndexSignature */: - case 229 /* EnumDeclaration */: - case 261 /* SourceFile */: + case 230 /* EnumDeclaration */: + case 262 /* SourceFile */: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, /*includeArrowFunctions*/ false); + if (container) { + switch (container.kind) { + case 150 /* Constructor */: + case 226 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; /** * Given an super call/property node, returns the closest node where * - a super call/property access is legal in the node and not legal in the parent node the node. @@ -7361,7 +7420,7 @@ var ts; case 142 /* ComputedPropertyName */: node = node.parent; break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: if (!stopOnFunctions) { @@ -7418,7 +7477,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return node.typeName; case 199 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) @@ -7453,25 +7512,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // classes are valid targets return true; case 147 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 226 /* ClassDeclaration */; + return node.parent.kind === 227 /* ClassDeclaration */; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 149 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 226 /* ClassDeclaration */; + && node.parent.kind === 227 /* ClassDeclaration */; case 144 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return node.parent.body !== undefined && (node.parent.kind === 150 /* Constructor */ || node.parent.kind === 149 /* MethodDeclaration */ || node.parent.kind === 152 /* SetAccessor */) - && node.parent.parent.kind === 226 /* ClassDeclaration */; + && node.parent.parent.kind === 227 /* ClassDeclaration */; } return false; } @@ -7487,7 +7546,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149 /* MethodDeclaration */: case 152 /* SetAccessor */: @@ -7497,9 +7556,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 /* JsxOpeningElement */ || - parent.kind === 247 /* JsxSelfClosingElement */ || - parent.kind === 249 /* JsxClosingElement */) { + if (parent.kind === 249 /* JsxOpeningElement */ || + parent.kind === 248 /* JsxSelfClosingElement */ || + parent.kind === 250 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7538,10 +7597,11 @@ var ts; case 194 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 198 /* OmittedExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: case 195 /* YieldExpression */: case 189 /* AwaitExpression */: + case 202 /* MetaProperty */: return true; case 141 /* QualifiedName */: while (node.parent.kind === 141 /* QualifiedName */) { @@ -7558,46 +7618,46 @@ var ts; case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: + case 261 /* EnumMember */: + case 258 /* PropertyAssignment */: case 174 /* BindingElement */: return parent_3.initializer === node; - case 207 /* ExpressionStatement */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 216 /* ReturnStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 220 /* ThrowStatement */: - case 218 /* SwitchStatement */: + case 208 /* ExpressionStatement */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 217 /* ReturnStatement */: + case 218 /* WithStatement */: + case 219 /* SwitchStatement */: + case 254 /* CaseClause */: + case 221 /* ThrowStatement */: + case 219 /* SwitchStatement */: return parent_3.expression === node; - case 211 /* ForStatement */: + case 212 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 225 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225 /* VariableDeclarationList */) || forInStatement.expression === node; case 182 /* TypeAssertionExpression */: case 200 /* AsExpression */: return node === parent_3.expression; - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return node === parent_3.expression; case 142 /* ComputedPropertyName */: return node === parent_3.expression; case 145 /* Decorator */: - case 252 /* JsxExpression */: - case 251 /* JsxSpreadAttribute */: - case 259 /* SpreadAssignment */: + case 253 /* JsxExpression */: + case 252 /* JsxSpreadAttribute */: + case 260 /* SpreadAssignment */: return true; case 199 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); @@ -7617,7 +7677,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */; + return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7626,7 +7686,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 245 /* ExternalModuleReference */; + return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 246 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7660,7 +7720,7 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224 /* VariableDeclaration */) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; } @@ -7713,35 +7773,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 245 /* ExternalModuleReference */) { + if (reference.kind === 246 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 241 /* ExportDeclaration */) { + if (node.kind === 242 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 231 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 /* ImportDeclaration */ + return node.kind === 236 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7752,8 +7812,8 @@ var ts; case 144 /* Parameter */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - case 258 /* ShorthandPropertyAssignment */: - case 257 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return node.questionToken !== undefined; @@ -7763,9 +7823,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 /* JSDocFunctionType */ && + return node.kind === 275 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 276 /* JSDocConstructorType */; + node.parameters[0].type.kind === 277 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -7778,7 +7838,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281 /* JSDocParameterTag */) { + if (doc.kind === 282 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } @@ -7810,9 +7870,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205 /* VariableStatement */; + parent.parent.parent.kind === 206 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205 /* VariableStatement */; + parent.parent.kind === 206 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7823,13 +7883,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 207 /* ExpressionStatement */; + parent.parent.kind === 208 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 /* ModuleDeclaration */ && - parent && parent.kind === 230 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 257 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 231 /* ModuleDeclaration */ && + parent && parent.kind === 231 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 258 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -7848,18 +7908,18 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 282 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -7869,7 +7929,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283 /* JSDocTypeTag */); + var tag = getFirstJSDocTag(node, 284 /* JSDocTypeTag */); if (!tag && node.kind === 144 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -7880,15 +7940,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 281 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 283 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 285 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -7901,8 +7961,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 275 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 276 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276 /* JSDocVariadicType */; })) { return true; } } @@ -7932,20 +7992,20 @@ var ts; case 191 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; case 183 /* ParenthesizedExpression */: case 175 /* ArrayLiteralExpression */: case 196 /* SpreadElement */: node = parent; break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } // Fall through - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: node = parent.parent; break; default: @@ -7962,6 +8022,18 @@ var ts; return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped + function isDeleteTarget(node) { + if (node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + return false; + } + node = node.parent; + while (node && node.kind === 183 /* ParenthesizedExpression */) { + node = node.parent; + } + return node && node.kind === 186 /* DeleteExpression */; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -7973,7 +8045,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 261 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 262 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7987,7 +8059,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 /* ImportSpecifier */ || parent.kind === 243 /* ExportSpecifier */) { + if (parent.kind === 240 /* ImportSpecifier */ || parent.kind === 244 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8014,8 +8086,8 @@ var ts; case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: + case 261 /* EnumMember */: + case 258 /* PropertyAssignment */: case 177 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; @@ -8029,10 +8101,10 @@ var ts; } return false; case 174 /* BindingElement */: - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8048,13 +8120,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 233 /* NamespaceExportDeclaration */ || - node.kind === 236 /* ImportClause */ && !!node.name || - node.kind === 237 /* NamespaceImport */ || - node.kind === 239 /* ImportSpecifier */ || - node.kind === 243 /* ExportSpecifier */ || - node.kind === 240 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 235 /* ImportEqualsDeclaration */ || + node.kind === 234 /* NamespaceExportDeclaration */ || + node.kind === 237 /* ImportClause */ && !!node.name || + node.kind === 238 /* NamespaceImport */ || + node.kind === 240 /* ImportSpecifier */ || + node.kind === 244 /* ExportSpecifier */ || + node.kind === 241 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8249,13 +8321,13 @@ var ts; var kind = node.kind; return kind === 150 /* Constructor */ || kind === 184 /* FunctionExpression */ - || kind === 225 /* FunctionDeclaration */ + || kind === 226 /* FunctionDeclaration */ || kind === 185 /* ArrowFunction */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ - || kind === 230 /* ModuleDeclaration */ - || kind === 261 /* SourceFile */; + || kind === 231 /* ModuleDeclaration */ + || kind === 262 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8387,14 +8459,13 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 197 /* ClassExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: case 194 /* TemplateExpression */: case 183 /* ParenthesizedExpression */: case 198 /* OmittedExpression */: - case 297 /* RawExpression */: return 19; case 181 /* TaggedTemplateExpression */: case 177 /* PropertyAccessExpression */: @@ -8578,13 +8649,12 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -9638,8 +9708,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9660,7 +9730,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 227 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9725,6 +9795,10 @@ var ts; return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188 /* VoidExpression */; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return isIdentifier(node) && node.autoGenerateKind > 0 /* None */; @@ -9797,18 +9871,18 @@ var ts; || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ || kind === 155 /* IndexSignature */ - || kind === 203 /* SemicolonClassElement */; + || kind === 204 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 /* PropertyAssignment */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 259 /* SpreadAssignment */ + return kind === 258 /* PropertyAssignment */ + || kind === 259 /* ShorthandPropertyAssignment */ + || kind === 260 /* SpreadAssignment */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ - || kind === 244 /* MissingDeclaration */; + || kind === 245 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -9871,7 +9945,7 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 174 /* BindingElement */: return true; @@ -9959,8 +10033,8 @@ var ts; || kind === 178 /* ElementAccessExpression */ || kind === 180 /* NewExpression */ || kind === 179 /* CallExpression */ - || kind === 246 /* JsxElement */ - || kind === 247 /* JsxSelfClosingElement */ + || kind === 247 /* JsxElement */ + || kind === 248 /* JsxSelfClosingElement */ || kind === 181 /* TaggedTemplateExpression */ || kind === 175 /* ArrayLiteralExpression */ || kind === 183 /* ParenthesizedExpression */ @@ -9979,7 +10053,7 @@ var ts; || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ || kind === 201 /* NonNullExpression */ - || kind === 297 /* RawExpression */; + || kind === 202 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10007,7 +10081,6 @@ var ts; || kind === 196 /* SpreadElement */ || kind === 200 /* AsExpression */ || kind === 198 /* OmittedExpression */ - || kind === 297 /* RawExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10021,11 +10094,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294 /* PartiallyEmittedExpression */; + return node.kind === 295 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293 /* NotEmittedStatement */; + return node.kind === 294 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10039,12 +10112,12 @@ var ts; ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 202 /* TemplateSpan */; + return node.kind === 203 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 204 /* Block */; + return node.kind === 205 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10062,121 +10135,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223 /* VariableDeclaration */; + return node.kind === 224 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224 /* VariableDeclarationList */; + return node.kind === 225 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232 /* CaseBlock */; + return node.kind === 233 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 /* ModuleBlock */ - || kind === 230 /* ModuleDeclaration */; + return kind === 232 /* ModuleBlock */ + || kind === 231 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */; + return node.kind === 235 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236 /* ImportClause */; + return node.kind === 237 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 /* NamedImports */ - || kind === 237 /* NamespaceImport */; + return kind === 239 /* NamedImports */ + || kind === 238 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239 /* ImportSpecifier */; + return node.kind === 240 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242 /* NamedExports */; + return node.kind === 243 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243 /* ExportSpecifier */; + return node.kind === 244 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 /* ModuleDeclaration */ || node.kind === 229 /* EnumDeclaration */; + return node.kind === 231 /* ModuleDeclaration */ || node.kind === 230 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 /* ArrowFunction */ || kind === 174 /* BindingElement */ - || kind === 226 /* ClassDeclaration */ + || kind === 227 /* ClassDeclaration */ || kind === 197 /* ClassExpression */ || kind === 150 /* Constructor */ - || kind === 229 /* EnumDeclaration */ - || kind === 260 /* EnumMember */ - || kind === 243 /* ExportSpecifier */ - || kind === 225 /* FunctionDeclaration */ + || kind === 230 /* EnumDeclaration */ + || kind === 261 /* EnumMember */ + || kind === 244 /* ExportSpecifier */ + || kind === 226 /* FunctionDeclaration */ || kind === 184 /* FunctionExpression */ || kind === 151 /* GetAccessor */ - || kind === 236 /* ImportClause */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 239 /* ImportSpecifier */ - || kind === 227 /* InterfaceDeclaration */ + || kind === 237 /* ImportClause */ + || kind === 235 /* ImportEqualsDeclaration */ + || kind === 240 /* ImportSpecifier */ + || kind === 228 /* InterfaceDeclaration */ || kind === 149 /* MethodDeclaration */ || kind === 148 /* MethodSignature */ - || kind === 230 /* ModuleDeclaration */ - || kind === 233 /* NamespaceExportDeclaration */ - || kind === 237 /* NamespaceImport */ + || kind === 231 /* ModuleDeclaration */ + || kind === 234 /* NamespaceExportDeclaration */ + || kind === 238 /* NamespaceImport */ || kind === 144 /* Parameter */ - || kind === 257 /* PropertyAssignment */ + || kind === 258 /* PropertyAssignment */ || kind === 147 /* PropertyDeclaration */ || kind === 146 /* PropertySignature */ || kind === 152 /* SetAccessor */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 228 /* TypeAliasDeclaration */ + || kind === 259 /* ShorthandPropertyAssignment */ + || kind === 229 /* TypeAliasDeclaration */ || kind === 143 /* TypeParameter */ - || kind === 223 /* VariableDeclaration */ - || kind === 285 /* JSDocTypedefTag */; + || kind === 224 /* VariableDeclaration */ + || kind === 286 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 225 /* FunctionDeclaration */ - || kind === 244 /* MissingDeclaration */ - || kind === 226 /* ClassDeclaration */ - || kind === 227 /* InterfaceDeclaration */ - || kind === 228 /* TypeAliasDeclaration */ - || kind === 229 /* EnumDeclaration */ - || kind === 230 /* ModuleDeclaration */ - || kind === 235 /* ImportDeclaration */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 241 /* ExportDeclaration */ - || kind === 240 /* ExportAssignment */ - || kind === 233 /* NamespaceExportDeclaration */; + return kind === 226 /* FunctionDeclaration */ + || kind === 245 /* MissingDeclaration */ + || kind === 227 /* ClassDeclaration */ + || kind === 228 /* InterfaceDeclaration */ + || kind === 229 /* TypeAliasDeclaration */ + || kind === 230 /* EnumDeclaration */ + || kind === 231 /* ModuleDeclaration */ + || kind === 236 /* ImportDeclaration */ + || kind === 235 /* ImportEqualsDeclaration */ + || kind === 242 /* ExportDeclaration */ + || kind === 241 /* ExportAssignment */ + || kind === 234 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 /* BreakStatement */ - || kind === 214 /* ContinueStatement */ - || kind === 222 /* DebuggerStatement */ - || kind === 209 /* DoStatement */ - || kind === 207 /* ExpressionStatement */ - || kind === 206 /* EmptyStatement */ - || kind === 212 /* ForInStatement */ - || kind === 213 /* ForOfStatement */ - || kind === 211 /* ForStatement */ - || kind === 208 /* IfStatement */ - || kind === 219 /* LabeledStatement */ - || kind === 216 /* ReturnStatement */ - || kind === 218 /* SwitchStatement */ - || kind === 220 /* ThrowStatement */ - || kind === 221 /* TryStatement */ - || kind === 205 /* VariableStatement */ - || kind === 210 /* WhileStatement */ - || kind === 217 /* WithStatement */ - || kind === 293 /* NotEmittedStatement */ - || kind === 296 /* EndOfDeclarationMarker */ - || kind === 295 /* MergeDeclarationMarker */; + return kind === 216 /* BreakStatement */ + || kind === 215 /* ContinueStatement */ + || kind === 223 /* DebuggerStatement */ + || kind === 210 /* DoStatement */ + || kind === 208 /* ExpressionStatement */ + || kind === 207 /* EmptyStatement */ + || kind === 213 /* ForInStatement */ + || kind === 214 /* ForOfStatement */ + || kind === 212 /* ForStatement */ + || kind === 209 /* IfStatement */ + || kind === 220 /* LabeledStatement */ + || kind === 217 /* ReturnStatement */ + || kind === 219 /* SwitchStatement */ + || kind === 221 /* ThrowStatement */ + || kind === 222 /* TryStatement */ + || kind === 206 /* VariableStatement */ + || kind === 211 /* WhileStatement */ + || kind === 218 /* WithStatement */ + || kind === 294 /* NotEmittedStatement */ + || kind === 297 /* EndOfDeclarationMarker */ + || kind === 296 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10197,24 +10270,24 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204 /* Block */; + || kind === 205 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 245 /* ExternalModuleReference */ + return kind === 246 /* ExternalModuleReference */ || kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 248 /* JsxOpeningElement */; + return node.kind === 249 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249 /* JsxClosingElement */; + return node.kind === 250 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -10226,64 +10299,64 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 /* JsxElement */ - || kind === 252 /* JsxExpression */ - || kind === 247 /* JsxSelfClosingElement */ + return kind === 247 /* JsxElement */ + || kind === 253 /* JsxExpression */ + || kind === 248 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 /* JsxAttribute */ - || kind === 251 /* JsxSpreadAttribute */; + return kind === 251 /* JsxAttribute */ + || kind === 252 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251 /* JsxSpreadAttribute */; + return node.kind === 252 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250 /* JsxAttribute */; + return node.kind === 251 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 252 /* JsxExpression */; + || kind === 253 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 /* CaseClause */ - || kind === 254 /* DefaultClause */; + return kind === 254 /* CaseClause */ + || kind === 255 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255 /* HeritageClause */; + return node.kind === 256 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256 /* CatchClause */; + return node.kind === 257 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 257 /* PropertyAssignment */; + return node.kind === 258 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258 /* ShorthandPropertyAssignment */; + return node.kind === 259 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 261 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 261 /* SourceFile */; + return node.kind === 262 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10515,7 +10588,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228 /* InterfaceDeclaration */) { return current; } } @@ -10535,14 +10608,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 225 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 206 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10558,14 +10631,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 225 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 206 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10634,7 +10707,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 /* SourceFile */ + var ConstructorForKind = kind === 262 /* SourceFile */ ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -11351,7 +11424,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(202 /* TemplateSpan */, location); + var node = createNode(203 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -11366,7 +11439,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(204 /* Block */, location, flags); + var block = createNode(205 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11382,7 +11455,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205 /* VariableStatement */, location, flags); + var node = createNode(206 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11397,7 +11470,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224 /* VariableDeclarationList */, location, flags); + var node = createNode(225 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11410,7 +11483,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223 /* VariableDeclaration */, location, flags); + var node = createNode(224 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11425,11 +11498,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206 /* EmptyStatement */, location); + return createNode(207 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207 /* ExpressionStatement */, location, flags); + var node = createNode(208 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11442,7 +11515,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208 /* IfStatement */, location); + var node = createNode(209 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11457,7 +11530,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209 /* DoStatement */, location); + var node = createNode(210 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11471,7 +11544,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210 /* WhileStatement */, location); + var node = createNode(211 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11485,7 +11558,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(212 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11501,7 +11574,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212 /* ForInStatement */, location); + var node = createNode(213 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11516,7 +11589,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213 /* ForOfStatement */, location); + var node = createNode(214 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11531,7 +11604,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214 /* ContinueStatement */, location); + var node = createNode(215 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11546,7 +11619,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215 /* BreakStatement */, location); + var node = createNode(216 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11561,7 +11634,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216 /* ReturnStatement */, location); + var node = createNode(217 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11574,7 +11647,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217 /* WithStatement */, location); + var node = createNode(218 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11588,7 +11661,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218 /* SwitchStatement */, location); + var node = createNode(219 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11602,7 +11675,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219 /* LabeledStatement */, location); + var node = createNode(220 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11616,7 +11689,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220 /* ThrowStatement */, location); + var node = createNode(221 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11629,7 +11702,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221 /* TryStatement */, location); + var node = createNode(222 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11644,7 +11717,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232 /* CaseBlock */, location); + var node = createNode(233 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11657,7 +11730,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225 /* FunctionDeclaration */, location, flags); + var node = createNode(226 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11677,7 +11750,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226 /* ClassDeclaration */, location); + var node = createNode(227 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11695,7 +11768,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235 /* ImportDeclaration */, location); + var node = createNode(236 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11711,7 +11784,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236 /* ImportClause */, location); + var node = createNode(237 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11725,7 +11798,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237 /* NamespaceImport */, location); + var node = createNode(238 /* NamespaceImport */, location); node.name = name; return node; } @@ -11738,7 +11811,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238 /* NamedImports */, location); + var node = createNode(239 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11751,7 +11824,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239 /* ImportSpecifier */, location); + var node = createNode(240 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11765,7 +11838,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240 /* ExportAssignment */, location); + var node = createNode(241 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11781,7 +11854,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241 /* ExportDeclaration */, location); + var node = createNode(242 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11797,7 +11870,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242 /* NamedExports */, location); + var node = createNode(243 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11810,7 +11883,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243 /* ExportSpecifier */, location); + var node = createNode(244 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11825,7 +11898,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246 /* JsxElement */, location); + var node = createNode(247 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11840,7 +11913,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247 /* JsxSelfClosingElement */, location); + var node = createNode(248 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11854,7 +11927,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248 /* JsxOpeningElement */, location); + var node = createNode(249 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11868,7 +11941,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249 /* JsxClosingElement */, location); + var node = createNode(250 /* JsxClosingElement */, location); node.tagName = tagName; return node; } @@ -11881,7 +11954,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250 /* JsxAttribute */, location); + var node = createNode(251 /* JsxAttribute */, location); node.name = name; node.initializer = initializer; return node; @@ -11895,7 +11968,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251 /* JsxSpreadAttribute */, location); + var node = createNode(252 /* JsxSpreadAttribute */, location); node.expression = expression; return node; } @@ -11907,22 +11980,23 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252 /* JsxExpression */, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253 /* JsxExpression */, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types, location) { - var node = createNode(255 /* HeritageClause */, location); + var node = createNode(256 /* HeritageClause */, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11936,7 +12010,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253 /* CaseClause */, location); + var node = createNode(254 /* CaseClause */, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11950,7 +12024,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254 /* DefaultClause */, location); + var node = createNode(255 /* DefaultClause */, location); node.statements = createNodeArray(statements); return node; } @@ -11963,7 +12037,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256 /* CatchClause */, location); + var node = createNode(257 /* CatchClause */, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11978,7 +12052,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer, location) { - var node = createNode(257 /* PropertyAssignment */, location); + var node = createNode(258 /* PropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11993,14 +12067,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258 /* ShorthandPropertyAssignment */, location); + var node = createNode(259 /* ShorthandPropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259 /* SpreadAssignment */, location); + var node = createNode(260 /* SpreadAssignment */, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -12022,7 +12096,7 @@ var ts; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261 /* SourceFile */, /*location*/ node, node.flags); + var updated = createNode(262 /* SourceFile */, /*location*/ node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12089,7 +12163,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(293 /* NotEmittedStatement */, /*location*/ original); + var node = createNode(294 /* NotEmittedStatement */, /*location*/ original); node.original = original; return node; } @@ -12099,7 +12173,7 @@ var ts; * order to properly emit exports. */ function createEndOfDeclarationMarker(original) { - var node = createNode(296 /* EndOfDeclarationMarker */); + var node = createNode(297 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12110,7 +12184,7 @@ var ts; * order to properly emit exports. */ function createMergeDeclarationMarker(original) { - var node = createNode(295 /* MergeDeclarationMarker */); + var node = createNode(296 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12125,7 +12199,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294 /* PartiallyEmittedExpression */, /*location*/ location || original); + var node = createNode(295 /* PartiallyEmittedExpression */, /*location*/ location || original); node.expression = expression; node.original = original; return node; @@ -12138,19 +12212,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - /** - * Creates a node that emits a string of raw text in an expression position. Raw text is never - * transformed, should be ES3 compliant, and should have the same precedence as - * PrimaryExpression. - * - * @param text The raw text of the node. - */ - function createRawExpression(text) { - var node = createNode(297 /* RawExpression */); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; // Compound nodes function createComma(left, right) { return createBinary(left, 25 /* CommaToken */, right); @@ -12326,6 +12387,20 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; + // Utilities + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 /* LabeledStatement */ + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12432,9 +12507,9 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -12999,7 +13074,7 @@ var ts; case 177 /* PropertyAccessExpression */: node = node.expression; continue; - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13054,7 +13129,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294 /* PartiallyEmittedExpression */) { + while (node.kind === 295 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13133,7 +13208,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -13391,10 +13466,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 236 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 242 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -13514,7 +13589,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13526,11 +13601,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13567,7 +13642,7 @@ var ts; // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; case 196 /* SpreadElement */: - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13591,7 +13666,7 @@ var ts; : propertyName; } break; - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13603,7 +13678,7 @@ var ts; : propertyName; } break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13717,20 +13792,20 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 234 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + case 235 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -13760,13 +13835,13 @@ var ts; } } break; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13774,7 +13849,7 @@ var ts; } } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -13794,7 +13869,7 @@ var ts; } } break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -13847,7 +13922,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261 /* SourceFile */) { + if (kind === 262 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { @@ -13903,20 +13978,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 223 /* VariableDeclaration */: + case 258 /* PropertyAssignment */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13942,7 +14017,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -14034,6 +14109,8 @@ var ts; visitNode(cbNode, node.type); case 201 /* NonNullExpression */: return visitNode(cbNode, node.expression); + case 202 /* MetaProperty */: + return visitNode(cbNode, node.name); case 193 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -14042,76 +14119,76 @@ var ts; visitNode(cbNode, node.whenFalse); case 196 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: return visitNode(cbNode, node.label); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 253 /* CaseClause */: + case 254 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145 /* Decorator */: return visitNode(cbNode, node.expression); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -14119,155 +14196,156 @@ var ts; visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return visitNodes(cbNodes, node.types); case 199 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245 /* ExternalModuleReference */: + case 246 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 252 /* JsxExpression */: - return visitNode(cbNode, node.expression); - case 249 /* JsxClosingElement */: + case 253 /* JsxExpression */: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 262 /* JSDocTypeExpression */: + case 263 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 266 /* JSDocUnionType */: + case 267 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 267 /* JSDocTupleType */: + case 268 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 265 /* JSDocArrayType */: + case 266 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 269 /* JSDocNonNullableType */: + case 270 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 268 /* JSDocNullableType */: + case 269 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 270 /* JSDocRecordType */: + case 271 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273 /* JSDocOptionalType */: + case 274 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275 /* JSDocVariadicType */: + case 276 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 276 /* JSDocConstructorType */: + case 277 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 277 /* JSDocThisType */: + case 278 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 271 /* JSDocRecordMember */: + case 272 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278 /* JSDocComment */: + case 279 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 281 /* JSDocParameterTag */: + case 282 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282 /* JSDocReturnTag */: + case 283 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 283 /* JSDocTypeTag */: + case 284 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 280 /* JSDocAugmentsTag */: + case 281 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocTemplateTag */: + case 285 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287 /* JSDocTypeLiteral */: + case 288 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286 /* JSDocPropertyTag */: + case 287 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 288 /* JSDocLiteralType */: + case 289 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14539,7 +14617,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(262 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -15327,7 +15405,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 147 /* PropertyDeclaration */: - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return true; case 149 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -15344,8 +15422,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: return true; } } @@ -15354,42 +15432,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 205 /* VariableStatement */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 207 /* ExpressionStatement */: - case 220 /* ThrowStatement */: - case 216 /* ReturnStatement */: - case 218 /* SwitchStatement */: - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 206 /* EmptyStatement */: - case 221 /* TryStatement */: - case 219 /* LabeledStatement */: - case 209 /* DoStatement */: - case 222 /* DebuggerStatement */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 226 /* FunctionDeclaration */: + case 206 /* VariableStatement */: + case 205 /* Block */: + case 209 /* IfStatement */: + case 208 /* ExpressionStatement */: + case 221 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 219 /* SwitchStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 212 /* ForStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: + case 207 /* EmptyStatement */: + case 222 /* TryStatement */: + case 220 /* LabeledStatement */: + case 210 /* DoStatement */: + case 223 /* DebuggerStatement */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: + case 241 /* ExportAssignment */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 229 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 261 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -15405,7 +15483,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223 /* VariableDeclaration */) { + if (node.kind !== 224 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15590,7 +15668,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202 /* TemplateSpan */); + var span = createNode(203 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -17179,8 +17257,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248 /* JsxOpeningElement */) { - var node = createNode(246 /* JsxElement */, opening.pos); + if (opening.kind === 249 /* JsxOpeningElement */) { + var node = createNode(247 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17190,7 +17268,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 248 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17264,7 +17342,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(248 /* JsxOpeningElement */, fullStart); + node = createNode(249 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -17276,7 +17354,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(247 /* JsxSelfClosingElement */, fullStart); + node = createNode(248 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17300,9 +17378,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252 /* JsxExpression */); + var node = createNode(253 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -17319,7 +17398,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250 /* JsxAttribute */); + var node = createNode(251 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -17334,7 +17413,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251 /* JsxSpreadAttribute */); + var node = createNode(252 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -17342,7 +17421,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249 /* JsxClosingElement */); + var node = createNode(250 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -17581,7 +17660,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(259 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(260 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17606,7 +17685,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(259 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -17617,7 +17696,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(258 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -17668,8 +17747,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180 /* NewExpression */); + var fullStart = scanner.getStartPos(); parseExpected(93 /* NewKeyword */); + if (parseOptional(22 /* DotToken */)) { + var node_1 = createNode(202 /* MetaProperty */, fullStart); + node_1.keywordToken = 93 /* NewKeyword */; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18 /* OpenParenToken */) { @@ -17679,7 +17765,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204 /* Block */); + var node = createNode(205 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17712,12 +17798,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206 /* EmptyStatement */); + var node = createNode(207 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(208 /* IfStatement */); + var node = createNode(209 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17727,7 +17813,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209 /* DoStatement */); + var node = createNode(210 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -17742,7 +17828,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210 /* WhileStatement */); + var node = createNode(211 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17765,21 +17851,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(212 /* ForInStatement */, pos); + var forInStatement = createNode(213 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140 /* OfKeyword */)) { - var forOfStatement = createNode(213 /* ForOfStatement */, pos); + var forOfStatement = createNode(214 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211 /* ForStatement */, pos); + var forStatement = createNode(212 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -17797,7 +17883,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 216 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17805,7 +17891,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216 /* ReturnStatement */); + var node = createNode(217 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -17814,7 +17900,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217 /* WithStatement */); + var node = createNode(218 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17823,7 +17909,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253 /* CaseClause */); + var node = createNode(254 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -17831,7 +17917,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254 /* DefaultClause */); + var node = createNode(255 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -17841,12 +17927,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218 /* SwitchStatement */); + var node = createNode(219 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(232 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(233 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -17861,7 +17947,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(220 /* ThrowStatement */); + var node = createNode(221 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -17869,7 +17955,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(221 /* TryStatement */); + var node = createNode(222 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -17882,7 +17968,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256 /* CatchClause */); + var result = createNode(257 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17892,7 +17978,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222 /* DebuggerStatement */); + var node = createNode(223 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -17904,13 +17990,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(219 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(220 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(208 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -18091,9 +18177,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(214 /* ContinueStatement */); + return parseBreakOrContinueStatement(215 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(215 /* BreakStatement */); + return parseBreakOrContinueStatement(216 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -18175,7 +18261,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(244 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18248,7 +18334,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223 /* VariableDeclaration */); + var node = createNode(224 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18257,7 +18343,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224 /* VariableDeclarationList */); + var node = createNode(225 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -18295,7 +18381,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205 /* VariableStatement */, fullStart); + var node = createNode(206 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18303,7 +18389,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* FunctionDeclaration */, fullStart); + var node = createNode(226 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -18527,7 +18613,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(203 /* SemicolonClassElement */); + var result = createNode(204 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18568,7 +18654,7 @@ var ts; /*modifiers*/ undefined, 197 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -18612,7 +18698,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(255 /* HeritageClause */); + var node = createNode(256 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -18635,7 +18721,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227 /* InterfaceDeclaration */, fullStart); + var node = createNode(228 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -18646,7 +18732,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* TypeAliasDeclaration */, fullStart); + var node = createNode(229 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136 /* TypeKeyword */); @@ -18662,13 +18748,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(260 /* EnumMember */, scanner.getStartPos()); + var node = createNode(261 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* EnumDeclaration */, fullStart); + var node = createNode(230 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -18683,7 +18769,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(232 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -18694,7 +18780,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(231 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -18708,7 +18794,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(231 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139 /* GlobalKeyword */) { @@ -18755,7 +18841,7 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(234 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); @@ -18774,7 +18860,7 @@ var ts; // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(234 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(235 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -18785,7 +18871,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(235 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(236 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -18808,7 +18894,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(236 /* ImportClause */, fullStart); + var importClause = createNode(237 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -18818,7 +18904,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(238 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(239 /* NamedImports */); } return finishNode(importClause); } @@ -18828,7 +18914,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(245 /* ExternalModuleReference */); + var node = createNode(246 /* ExternalModuleReference */); parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -18851,7 +18937,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(237 /* NamespaceImport */); + var namespaceImport = createNode(238 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -18866,14 +18952,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 238 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 239 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243 /* ExportSpecifier */); + return parseImportOrExportSpecifier(244 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239 /* ImportSpecifier */); + return parseImportOrExportSpecifier(240 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18898,14 +18984,14 @@ var ts; else { node.name = identifierName; } - if (kind === 239 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 240 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241 /* ExportDeclaration */, fullStart); + var node = createNode(242 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { @@ -18913,7 +18999,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(243 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. @@ -18926,7 +19012,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240 /* ExportAssignment */, fullStart); + var node = createNode(241 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -19008,10 +19094,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */ - || node.kind === 235 /* ImportDeclaration */ - || node.kind === 240 /* ExportAssignment */ - || node.kind === 241 /* ExportDeclaration */ + || node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */ + || node.kind === 236 /* ImportDeclaration */ + || node.kind === 241 /* ExportAssignment */ + || node.kind === 242 /* ExportDeclaration */ ? node : undefined; }); @@ -19086,7 +19172,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(262 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(263 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -19097,12 +19183,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(266 /* JSDocUnionType */, type.pos); + var unionType = createNode(267 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(273 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(274 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19113,20 +19199,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(265 /* JSDocArrayType */, type.pos); + var arrayType = createNode(266 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(268 /* JSDocNullableType */, type.pos); + var nullableType = createNode(269 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(269 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(270 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19178,27 +19264,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277 /* JSDocThisType */); + var result = createNode(278 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276 /* JSDocConstructorType */); + var result = createNode(277 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275 /* JSDocVariadicType */); + var result = createNode(276 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274 /* JSDocFunctionType */); + var result = createNode(275 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -19220,7 +19306,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272 /* JSDocTypeReference */); + var result = createNode(273 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -19261,18 +19347,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270 /* JSDocRecordType */); + var result = createNode(271 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269 /* JSDocNonNullableType */); + var result = createNode(270 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267 /* JSDocTupleType */); + var result = createNode(268 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -19286,7 +19372,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266 /* JSDocUnionType */); + var result = createNode(267 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -19302,12 +19388,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263 /* JSDocAllType */); + var result = createNode(264 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288 /* JSDocLiteralType */); + var result = createNode(289 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19330,11 +19416,11 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(264 /* JSDocUnknownType */, pos); + var result = createNode(265 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(268 /* JSDocNullableType */, pos); + var result = createNode(269 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19499,7 +19585,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(278 /* JSDocComment */, start); + var result = createNode(279 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19615,7 +19701,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279 /* JSDocTag */, atToken.pos); + var result = createNode(280 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19672,7 +19758,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281 /* JSDocParameterTag */, atToken.pos); + var result = createNode(282 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19683,20 +19769,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282 /* JSDocReturnTag */, atToken.pos); + var result = createNode(283 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283 /* JSDocTypeTag */, atToken.pos); + var result = createNode(284 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19711,7 +19797,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(287 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19720,7 +19806,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(281 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19729,7 +19815,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(286 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); @@ -19743,7 +19829,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 273 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { var name_14 = jsDocTypeReference.name; @@ -19761,7 +19847,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19802,7 +19888,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(230 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(231 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -19848,7 +19934,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' @@ -19872,7 +19958,7 @@ var ts; break; } } - var result = createNode(284 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(285 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20346,7 +20432,7 @@ var ts; if (position >= array.pos && position < array.end) { // position was in this array. Search through this array to see if we find a // viable element. - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -20392,16 +20478,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 229 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 231 /* ModuleBlock */) { + else if (node.kind === 232 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20420,7 +20506,7 @@ var ts; }); return state_1; } - else if (node.kind === 230 /* ModuleDeclaration */) { + else if (node.kind === 231 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -20561,7 +20647,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20596,9 +20682,9 @@ var ts; return "__new"; case 155 /* IndexSignature */: return "__index"; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return "__export"; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; case 192 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -20615,22 +20701,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: + case 226 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 274 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 275 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 206 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -20717,7 +20803,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20737,7 +20823,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 243 /* ExportSpecifier */ || (node.kind === 234 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 244 /* ExportSpecifier */ || (node.kind === 235 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20760,7 +20846,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 285 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -20847,7 +20933,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -20926,43 +21012,43 @@ var ts; return; } switch (node.kind) { - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: bindWhileStatement(node); break; - case 209 /* DoStatement */: + case 210 /* DoStatement */: bindDoStatement(node); break; - case 211 /* ForStatement */: + case 212 /* ForStatement */: bindForStatement(node); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 208 /* IfStatement */: + case 209 /* IfStatement */: bindIfStatement(node); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 221 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 221 /* TryStatement */: + case 222 /* TryStatement */: bindTryStatement(node); break; - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: bindSwitchStatement(node); break; - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: bindCaseBlock(node); break; - case 253 /* CaseClause */: + case 254 /* CaseClause */: bindCaseClause(node); break; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: bindLabeledStatement(node); break; case 190 /* PrefixUnaryExpression */: @@ -20980,7 +21066,7 @@ var ts; case 193 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; case 179 /* CallExpression */: @@ -21147,11 +21233,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* IfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: + case 209 /* IfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: return parent.expression === node; - case 211 /* ForStatement */: + case 212 /* ForStatement */: case 193 /* ConditionalExpression */: return parent.condition === node; } @@ -21215,7 +21301,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 220 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21252,7 +21338,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224 /* VariableDeclarationList */) { + if (node.initializer.kind !== 225 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21274,7 +21360,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216 /* ReturnStatement */) { + if (node.kind === 217 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21294,7 +21380,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21360,7 +21446,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21427,7 +21513,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 210 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); @@ -21459,13 +21545,13 @@ var ts; else if (node.kind === 176 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257 /* PropertyAssignment */) { + if (p.kind === 258 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258 /* ShorthandPropertyAssignment */) { + else if (p.kind === 259 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259 /* SpreadAssignment */) { + else if (p.kind === 260 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21565,7 +21651,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 /* ForInStatement */ || node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 213 /* ForInStatement */ || node.parent.parent.kind === 214 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -21595,28 +21681,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: + case 271 /* JSDocRecordType */: return 1 /* IsContainer */; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 274 /* JSDocFunctionType */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 275 /* JSDocFunctionType */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: case 170 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 261 /* SourceFile */: + case 262 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 149 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: @@ -21629,17 +21715,17 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 147 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 256 /* CatchClause */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 232 /* CaseBlock */: + case 257 /* CatchClause */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 233 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 204 /* Block */: + case 205 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -21676,20 +21762,20 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161 /* TypeLiteral */: case 176 /* ObjectLiteralExpression */: - case 227 /* InterfaceDeclaration */: - case 270 /* JSDocRecordType */: - case 287 /* JSDocTypeLiteral */: + case 228 /* InterfaceDeclaration */: + case 271 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the @@ -21706,11 +21792,11 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: - case 228 /* TypeAliasDeclaration */: + case 275 /* JSDocFunctionType */: + case 229 /* TypeAliasDeclaration */: case 170 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, @@ -21732,11 +21818,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 261 /* SourceFile */ || body.kind === 231 /* ModuleBlock */)) { + var body = node.kind === 262 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 262 /* SourceFile */ || body.kind === 232 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 /* ExportDeclaration */ || stat.kind === 240 /* ExportAssignment */) { + if (stat.kind === 242 /* ExportDeclaration */ || stat.kind === 241 /* ExportAssignment */) { return true; } } @@ -21829,7 +21915,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 260 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -21841,7 +21927,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ + var currentKind = prop.kind === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -21863,10 +21949,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21977,8 +22063,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 261 /* SourceFile */ && - blockScopeContainer.kind !== 230 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 262 /* SourceFile */ && + blockScopeContainer.kind !== 231 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22091,14 +22177,14 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 286 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -22131,7 +22217,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return checkStrictModeCatchClause(node); case 186 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); @@ -22141,7 +22227,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return checkStrictModeWithStatement(node); case 167 /* ThisType */: seenThisKeyword = true; @@ -22152,22 +22238,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); case 144 /* Parameter */: return bindParameter(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 271 /* JSDocRecordMember */: + case 272 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 286 /* JSDocPropertyTag */: + case 287 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 259 /* SpreadAssignment */: - case 251 /* JsxSpreadAttribute */: + case 260 /* SpreadAssignment */: + case 252 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { @@ -22192,7 +22278,7 @@ var ts; // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 150 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -22202,12 +22288,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); case 161 /* TypeLiteral */: case 170 /* MappedType */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: + case 271 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); case 176 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); @@ -22221,46 +22307,46 @@ var ts; break; // Members of classes, interfaces, and modules case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 234 /* ImportEqualsDeclaration */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return bindImportClause(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return bindExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return bindExportAssignment(node); - case 261 /* SourceFile */: + case 262 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204 /* Block */: + case 205 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -22292,7 +22378,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 240 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22302,7 +22388,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261 /* SourceFile */) { + if (node.parent.kind !== 262 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -22357,7 +22443,7 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 225 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { + if (container.kind === 226 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); @@ -22405,7 +22491,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22541,13 +22627,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 206 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 207 /* EmptyStatement */) || // report error on class declarations - node.kind === 226 /* ClassDeclaration */ || + node.kind === 227 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 230 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 229 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 230 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -22561,7 +22647,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 /* VariableStatement */ || + (node.kind !== 206 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -22585,13 +22671,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); case 183 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); case 192 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 144 /* Parameter */: return computeParameter(node, subtreeFlags); @@ -22599,23 +22685,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); case 197 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return computeCatchClause(node, subtreeFlags); case 199 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -22628,7 +22714,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); case 177 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); @@ -23113,8 +23199,8 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: case 182 /* TypeAssertionExpression */: case 200 /* AsExpression */: case 201 /* NonNullExpression */: @@ -23122,18 +23208,18 @@ var ts; // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: case 10 /* JsxText */: - case 249 /* JsxClosingElement */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - case 252 /* JsxExpression */: + case 250 /* JsxClosingElement */: + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: + case 253 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: // for-of might be ESNext if it has a rest destructuring transformFlags |= 8 /* AssertESNext */; // FALLTHROUGH @@ -23143,8 +23229,9 @@ var ts; case 15 /* TemplateTail */: case 194 /* TemplateExpression */: case 181 /* TaggedTemplateExpression */: - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: case 114 /* StaticKeyword */: + case 202 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -23176,8 +23263,8 @@ var ts; case 164 /* UnionType */: case 165 /* IntersectionType */: case 166 /* ParenthesizedType */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: case 167 /* ThisType */: case 168 /* TypeOperator */: case 169 /* IndexedAccessType */: @@ -23207,7 +23294,7 @@ var ts; case 196 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 96 /* SuperKeyword */: @@ -23266,23 +23353,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 216 /* ReturnStatement */: - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 217 /* ReturnStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23306,18 +23393,18 @@ var ts; case 180 /* NewExpression */: case 175 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; case 144 /* Parameter */: return 536872257 /* ParameterExcludes */; case 185 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return 539358529 /* ClassExcludes */; case 150 /* Constructor */: @@ -23339,12 +23426,12 @@ var ts; case 153 /* CallSignature */: case 154 /* ConstructSignature */: case 155 /* IndexSignature */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; case 176 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 256 /* CatchClause */: + case 257 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; case 172 /* ObjectBindingPattern */: case 173 /* ArrayBindingPattern */: @@ -23386,10 +23473,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - /** Create Resolved from a file with unknown extension. */ - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; @@ -23402,13 +23485,14 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + /** Reads from "main" or "types"/"typings" depending on `extensions`. */ + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2 /* DtsOnly */: - case 0 /* TypeScript */: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1 /* JavaScript */: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -23475,6 +23559,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -23535,7 +23620,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -23552,7 +23641,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -23605,31 +23695,134 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + /** + * At first this function add entry directory -> module resolution result to the table. + * Then it computes the set of parent folders for 'directory' that should have the same module resolution result + * and for every parent folder in set it adds entry: parent -> module resolution. . + * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. + * Set of parent folders that should have the same result will be: + * [ + * /a/b/c/d, /a/b/c, /a/b + * ] + * this means that request for module resolution from file in any of these folder will be immediately found in cache. + */ + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + // if entry is already in cache do nothing + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + // find common prefix between directory and resolved file name + // this common prefix should be the shorted path that has the same resolution + // directory: /a/b/c/d/e + // resolvedFileName: /a/b/foo.d.ts + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_5 = ts.getDirectoryPath(current); + if (parent_5 === current || directoryPathMap.contains(parent_5)) { + break; + } + directoryPathMap.set(parent_5, result); + current = parent_5; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + // find first position where directory and resolution differs + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + // find last directory separator before position i + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + // put result in per-module name cache + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -23822,34 +24015,34 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -23866,10 +24059,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -23908,11 +24124,11 @@ var ts; } } switch (extensions) { - case 2 /* DtsOnly */: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0 /* TypeScript */: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1 /* JavaScript */: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -23922,19 +24138,21 @@ var ts; } /** Return the file if it exists. */ function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -23943,18 +24161,23 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - // Note: this would allow a package.json to specify a ".js" file as typings. Maybe that should be forbidden. - return resolvedFromAnyFile(fromFile); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0 /* TypeScript */, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -23964,7 +24187,7 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results @@ -23972,70 +24195,116 @@ var ts; } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + /** True if `extension` is one of the supported `extensions`. */ + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNodeModulesWorker(2 /* DtsOnly */, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true, /*cache*/ undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1 /* JavaScript */) { - return loadModuleFromNodeModulesFolder(2 /* DtsOnly */, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0 /* TypeScript */) { + if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); } } } @@ -24052,10 +24321,17 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2 /* DtsOnly */, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + /** + * Wraps value to SearchResult. + * @returns undefined if value is undefined or { value } otherwise + */ + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { @@ -24142,9 +24418,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -24153,6 +24431,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -24177,7 +24456,8 @@ var ts; // we deliberately exclude augmentations // since we are only interested in declarations of the module itself return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -24281,6 +24561,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var TypeFacts; @@ -24501,7 +24782,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 230 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 231 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 231 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -24606,7 +24887,7 @@ var ts; return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -24662,9 +24943,21 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 223 /* VariableDeclaration */ || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174 /* BindingElement */) { + // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) + var errorBindingElement = ts.getAncestor(usage, 174 /* BindingElement */); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224 /* VariableDeclaration */), usage); + } + else if (declaration.kind === 224 /* VariableDeclaration */) { + // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) @@ -24673,9 +24966,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205 /* VariableStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 206 /* VariableStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -24684,8 +24977,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -24713,6 +25006,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -24736,7 +25038,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 278 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 279 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || lastLocation.kind === 144 /* Parameter */ || @@ -24763,13 +25065,13 @@ var ts; } } switch (location.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 262 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports["default"]) { @@ -24792,7 +25094,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 243 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 244 /* ExportSpecifier */)) { break; } } @@ -24800,7 +25102,7 @@ var ts; break loop; } break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -24823,9 +25125,9 @@ var ts; } } break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -24854,7 +25156,7 @@ var ts; // case 142 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -24867,7 +25169,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; @@ -24960,7 +25262,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 234 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -25048,7 +25350,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -25069,10 +25371,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 235 /* ImportDeclaration */) { + while (node && node.kind !== 236 /* ImportDeclaration */) { node = node.parent; } return node; @@ -25082,7 +25384,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -25207,19 +25509,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return getTargetOfImportClause(node); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -25266,11 +25568,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240 /* ExportAssignment */) { + if (node.kind === 241 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 243 /* ExportSpecifier */) { + else if (node.kind === 244 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -25298,14 +25600,16 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 234 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 235 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - // Resolves a qualified name and any involved aliases + /** + * Resolves a qualified name and any involved aliases. + */ function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) { if (ts.nodeIsMissing(name)) { return undefined; @@ -25626,11 +25930,11 @@ var ts; } } switch (location_1.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -25682,7 +25986,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -25722,7 +26026,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -25821,7 +26125,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25867,7 +26171,7 @@ var ts; meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 177 /* PropertyAccessExpression */ || - entityName.parent.kind === 234 /* ImportEqualsDeclaration */) { + entityName.parent.kind === 235 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -25966,7 +26270,7 @@ var ts; while (node.kind === 166 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -25974,7 +26278,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 /* ModuleBlock */ && + node.parent.kind === 232 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -26066,9 +26370,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -26218,14 +26522,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -26291,7 +26595,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 /* SourceFile */ || declaration.parent.kind === 231 /* ModuleBlock */; + return declaration.parent.kind === 262 /* SourceFile */ || declaration.parent.kind === 232 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -26305,25 +26609,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); - writeSpace(writer); - } - writePunctuation(writer, 20 /* OpenBracketToken */); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21 /* CloseBracketToken */); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeType(info.type, 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130 /* ReadonlyKeyword */); @@ -26407,8 +26692,8 @@ var ts; writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 132 /* NumberKeyword */); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0 /* String */, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1 /* Number */, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -26588,6 +26873,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 /* SuppressAnyReturnType */ && isTypeAny(returnType)) { + return; + } if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); writePunctuation(writer, 35 /* EqualsGreaterThanToken */); @@ -26600,7 +26889,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -26620,6 +26908,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 20 /* OpenBracketToken */); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + switch (kind) { + case 1 /* Number */: + writeKeyword(writer, 132 /* NumberKeyword */); + break; + case 0 /* String */: + writeKeyword(writer, 134 /* StringKeyword */); + break; + } + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24 /* SemicolonToken */); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -26630,6 +26944,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -26646,32 +26961,32 @@ var ts; switch (node.kind) { case 174 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 225 /* FunctionDeclaration */: - case 229 /* EnumDeclaration */: - case 234 /* ImportEqualsDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 226 /* FunctionDeclaration */: + case 230 /* EnumDeclaration */: + case 235 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 234 /* ImportEqualsDeclaration */ && parent_7.kind !== 261 /* SourceFile */ && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 /* ImportEqualsDeclaration */ && parent_8.kind !== 262 /* SourceFile */ && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 151 /* GetAccessor */: @@ -26688,7 +27003,7 @@ var ts; case 153 /* CallSignature */: case 155 /* IndexSignature */: case 144 /* Parameter */: - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: case 158 /* FunctionType */: case 159 /* ConstructorType */: case 161 /* TypeLiteral */: @@ -26701,18 +27016,18 @@ var ts; return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: return false; // Type parameters are always visible case 143 /* TypeParameter */: // Source file and namespace export are always visible - case 261 /* SourceFile */: - case 233 /* NamespaceExportDeclaration */: + case 262 /* SourceFile */: + case 234 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return false; default: return false; @@ -26721,10 +27036,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 241 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243 /* ExportSpecifier */) { + else if (node.parent.kind === 244 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -26817,12 +27132,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223 /* VariableDeclaration */: - case 224 /* VariableDeclarationList */: - case 239 /* ImportSpecifier */: - case 238 /* NamedImports */: - case 237 /* NamespaceImport */: - case 236 /* ImportClause */: + case 224 /* VariableDeclaration */: + case 225 /* VariableDeclarationList */: + case 240 /* ImportSpecifier */: + case 239 /* NamedImports */: + case 238 /* NamespaceImport */: + case 237 /* ImportClause */: node = node.parent; break; default: @@ -26846,9 +27161,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192 /* Never */) !== 0; - } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node) { @@ -27007,11 +27319,11 @@ var ts; } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 212 /* ForInStatement */) { + if (declaration.parent.parent.kind === 213 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 214 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -27026,7 +27338,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 223 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27074,7 +27386,7 @@ var ts; return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 258 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 259 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27177,7 +27489,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - if (declaration.kind === 257 /* PropertyAssignment */) { + if (declaration.kind === 258 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27210,10 +27522,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 240 /* ExportAssignment */) { + if (declaration.kind === 241 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 287 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27443,8 +27755,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || - node.kind === 225 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || + if (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || + node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { @@ -27455,7 +27767,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -27464,8 +27776,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 226 /* ClassDeclaration */ || - node.kind === 197 /* ClassExpression */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 227 /* ClassDeclaration */ || + node.kind === 197 /* ClassExpression */ || node.kind === 229 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -27497,11 +27809,13 @@ var ts; } return signatures; } - // The base constructor of a class can resolve to - // undefinedType if the class has no extends clause, - // unknownType if an error occurred during resolution of the extends expression, - // nullType if the extends expression is the null value, or - // an object type with at least one construct signature. + /** + * The base constructor of a class can resolve to + * * undefinedType if the class has no extends clause, + * * unknownType if an error occurred during resolution of the extends expression, + * * nullType if the extends expression is the null value, or + * * an object type with at least one construct signature. + */ function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -27616,7 +27930,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -27648,7 +27962,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 228 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -27705,7 +28019,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 286 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -27716,7 +28030,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 229 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -27750,7 +28064,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 230 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -27778,7 +28092,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 230 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -28176,6 +28490,9 @@ var ts; } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } + /** + * Converts an AnonymousType to a ResolvedType. + */ function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { @@ -28306,8 +28623,8 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -28618,7 +28935,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 273 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 274 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -28629,7 +28946,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 274 /* JSDocOptionalType */; } } } @@ -28685,7 +29002,7 @@ var ts; // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature @@ -28773,12 +29090,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: @@ -28789,7 +29106,7 @@ var ts; case 152 /* SetAccessor */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -29080,7 +29397,7 @@ var ts; switch (node.kind) { case 157 /* TypeReference */: return node.typeName; - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return node.name; case 199 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other @@ -29108,7 +29425,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 272 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 273 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -29121,7 +29438,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272 /* JSDocTypeReference */) { + if (node.kind === 273 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -29163,9 +29480,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: return declaration; } } @@ -29358,8 +29675,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -29479,8 +29797,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -29618,7 +29936,7 @@ var ts; getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -29745,7 +30063,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -29875,7 +30193,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -29894,8 +30212,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 263 /* JSDocAllType */: - case 264 /* JSDocUnknownType */: + case 264 /* JSDocAllType */: + case 265 /* JSDocUnknownType */: return anyType; case 134 /* StringKeyword */: return stringType; @@ -29913,21 +30231,21 @@ var ts; return nullType; case 129 /* NeverKeyword */: return neverType; - case 289 /* JSDocNullKeyword */: + case 290 /* JSDocNullKeyword */: return nullType; - case 290 /* JSDocUndefinedKeyword */: + case 291 /* JSDocUndefinedKeyword */: return undefinedType; - case 291 /* JSDocNeverKeyword */: + case 292 /* JSDocNeverKeyword */: return neverType; case 167 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); case 171 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 288 /* JSDocLiteralType */: + case 289 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return getTypeFromTypeReference(node); case 156 /* TypePredicate */: return booleanType; @@ -29936,29 +30254,29 @@ var ts; case 160 /* TypeQuery */: return getTypeFromTypeQueryNode(node); case 162 /* ArrayType */: - case 265 /* JSDocArrayType */: + case 266 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); case 163 /* TupleType */: return getTypeFromTupleTypeNode(node); case 164 /* UnionType */: - case 266 /* JSDocUnionType */: + case 267 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); case 165 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); case 166 /* ParenthesizedType */: - case 268 /* JSDocNullableType */: - case 269 /* JSDocNonNullableType */: - case 276 /* JSDocConstructorType */: - case 277 /* JSDocThisType */: - case 273 /* JSDocOptionalType */: + case 269 /* JSDocNullableType */: + case 270 /* JSDocNonNullableType */: + case 277 /* JSDocConstructorType */: + case 278 /* JSDocThisType */: + case 274 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 270 /* JSDocRecordType */: + case 271 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); case 158 /* FunctionType */: case 159 /* ConstructorType */: case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 274 /* JSDocFunctionType */: + case 288 /* JSDocTypeLiteral */: + case 275 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -29972,9 +30290,9 @@ var ts; case 141 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267 /* JSDocTupleType */: + case 268 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 275 /* JSDocVariadicType */: + case 276 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30136,17 +30454,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144 /* Index */) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384 /* TypeParameter */) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -30170,12 +30490,12 @@ var ts; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first // declaration since multiple declarations will all have the same parent anyway. - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: @@ -30186,10 +30506,10 @@ var ts; case 152 /* SetAccessor */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -30199,15 +30519,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 228 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: + case 275 /* JSDocFunctionType */: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231 /* ModuleDeclaration */: + case 262 /* SourceFile */: return false; } node = node.parent; @@ -30217,7 +30546,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 /* SourceFile */ || parentKind === 231 /* ModuleBlock */; + return parentKind === 262 /* SourceFile */ || parentKind === 232 /* ModuleBlock */; } return false; } @@ -30309,7 +30638,7 @@ var ts; case 192 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return isContextSensitive(node.initializer); case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -30376,7 +30705,7 @@ var ts; // subtype of T but not structurally identical to T. This specifically means that two distinct but // structurally identical types (such as two classes) are not considered instances of each other. function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } /** * This is *not* a bi-directional relationship. @@ -30710,10 +31039,12 @@ var ts; } return false; } - // Compare two types and return - // Ternary.True if they are related with no assumptions, - // Ternary.Maybe if they are related with assumptions of other relationships, or - // Ternary.False if they are not related. + /** + * Compare two types and return + * * Ternary.True if they are related with no assumptions, + * * Ternary.Maybe if they are related with assumptions of other relationships, or + * * Ternary.False if they are not related. + */ function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { @@ -31177,8 +31508,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1 /* True */; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { + return -1 /* True */; + } } return 0 /* False */; } @@ -31345,7 +31679,7 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; @@ -31584,8 +31918,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -31593,8 +31927,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -31700,8 +32034,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -31883,7 +32217,7 @@ var ts; case 174 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -32269,8 +32603,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32411,7 +32745,7 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && + (target.kind === 224 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; @@ -32516,8 +32850,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -32605,7 +32939,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 257 /* PropertyAssignment */ ? + return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 258 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -32624,9 +32958,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return stringType; - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); @@ -32636,9 +32970,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -32664,26 +32998,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212 /* ForInStatement */) { + if (node.parent.parent.kind === 213 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.parent.kind === 214 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 /* VariableDeclaration */ ? + return node.kind === 224 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? + return node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 /* VariableDeclaration */ && node.initializer && + return node.kind === 224 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); @@ -32710,7 +33044,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 254 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -32825,8 +33159,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33461,8 +33795,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 /* ModuleBlock */ || - node.kind === 261 /* SourceFile */ || + node.kind === 232 /* ModuleBlock */ || + node.kind === 262 /* SourceFile */ || node.kind === 147 /* PropertyDeclaration */) { return node; } @@ -33542,7 +33876,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration_1.kind === 226 /* ClassDeclaration */ + if (declaration_1.kind === 227 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -33573,6 +33907,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -33611,7 +33946,7 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph @@ -33646,7 +33981,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 256 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 257 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -33671,8 +34006,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 211 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 224 /* VariableDeclarationList */).parent === container && + if (container.kind === 212 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 225 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -33793,11 +34128,11 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; @@ -33861,9 +34196,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 275 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -34254,8 +34589,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -34338,13 +34673,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250 /* JsxAttribute */) { + if (attribute.kind === 251 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251 /* JsxSpreadAttribute */) { + else if (attribute.kind === 252 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -34382,14 +34717,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 174 /* BindingElement */: return getContextualTypeForInitializerExpression(node); case 185 /* ArrowFunction */: - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); case 195 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); @@ -34401,22 +34736,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); case 175 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); case 193 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183 /* ParenthesizedExpression */: return getContextualType(parent); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return getContextualType(parent); - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -34477,8 +34812,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -34683,18 +35018,18 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 /* PropertyAssignment */ || - memberDecl.kind === 258 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 258 /* PropertyAssignment */ || + memberDecl.kind === 259 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257 /* PropertyAssignment */) { + if (memberDecl.kind === 258 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 259 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -34702,8 +35037,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 257 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -34731,7 +35066,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259 /* SpreadAssignment */) { + else if (memberDecl.kind === 260 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -34842,13 +35177,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: checkJsxExpression(child); break; - case 246 /* JsxElement */: + case 247 /* JsxElement */: checkJsxElement(child); break; - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -35223,11 +35558,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250 /* JsxAttribute */) { + if (node.attributes[i].kind === 251 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 252 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -35248,7 +35583,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -35276,7 +35615,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 223 /* VariableDeclaration */ ? + var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 224 /* VariableDeclaration */ ? node.name : node.right; if (left.kind === 96 /* SuperKeyword */) { @@ -35453,7 +35792,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer.kind === 225 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35482,7 +35821,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 /* ForInStatement */ && + if (node.kind === 213 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35591,13 +35930,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } @@ -35605,7 +35944,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -35909,7 +36248,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145 /* Decorator */) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; @@ -35953,7 +36292,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); @@ -35998,7 +36337,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -36049,7 +36388,7 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -36554,7 +36893,7 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144 /* Parameter */: @@ -36693,9 +37032,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 225 /* FunctionDeclaration */ + ? 226 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 223 /* VariableDeclaration */ + ? 224 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -36722,6 +37061,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150 /* Constructor */) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -36863,7 +37219,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204 /* Block */) { + if (func.body.kind !== 205 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -36953,7 +37309,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -37015,7 +37371,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -37095,6 +37451,7 @@ var ts; if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -37115,7 +37472,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204 /* Block */) { + if (node.body.kind === 205 /* Block */) { checkSourceElement(node.body); } else { @@ -37184,7 +37541,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237 /* NamespaceImport */; + return declaration && declaration.kind === 238 /* NamespaceImport */; } } } @@ -37201,6 +37558,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 /* PropertyAccessExpression */ && expr.kind !== 178 /* ElementAccessExpression */) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -37276,8 +37643,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -37294,8 +37661,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -37304,8 +37671,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -37363,7 +37730,7 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 /* PropertyAssignment */ || property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 258 /* PropertyAssignment */ || property.kind === 259 /* ShorthandPropertyAssignment */) { var name_20 = property.name; if (name_20.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(name_20); @@ -37378,7 +37745,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 259 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -37390,7 +37757,7 @@ var ts; error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); } } - else if (property.kind === 259 /* SpreadAssignment */) { + else if (property.kind === 260 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -37463,7 +37830,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 259 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -37493,7 +37860,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 /* SpreadAssignment */ ? + var error = target.parent.kind === 260 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -37530,8 +37897,8 @@ var ts; case 176 /* ObjectLiteralExpression */: case 187 /* TypeOfExpression */: case 201 /* NonNullExpression */: - case 247 /* JsxSelfClosingElement */: - case 246 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: return true; case 193 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && @@ -38038,6 +38405,8 @@ var ts; return checkAssertion(node); case 201 /* NonNullExpression */: return checkNonNullAssertion(node); + case 202 /* MetaProperty */: + return checkMetaProperty(node); case 186 /* DeleteExpression */: return checkDeleteExpression(node); case 188 /* VoidExpression */: @@ -38058,13 +38427,13 @@ var ts; return undefinedWideningType; case 195 /* YieldExpression */: return checkYieldExpression(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return checkJsxExpression(node); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return checkJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -38118,7 +38487,7 @@ var ts; return false; } return node.kind === 149 /* MethodDeclaration */ || - node.kind === 225 /* FunctionDeclaration */ || + node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -38179,14 +38548,14 @@ var ts; switch (node.parent.kind) { case 185 /* ArrowFunction */: case 153 /* CallSignature */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 158 /* FunctionType */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -38215,7 +38584,7 @@ var ts; if (node.kind === 155 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 /* FunctionType */ || node.kind === 225 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || + else if (node.kind === 158 /* FunctionType */ || node.kind === 226 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -38349,7 +38718,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227 /* InterfaceDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -38445,7 +38814,7 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 225 /* FunctionDeclaration */) { + else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 226 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -38480,7 +38849,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38641,8 +39010,8 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 227 /* InterfaceDeclaration */ && - n.parent.kind !== 226 /* ClassDeclaration */ && + if (n.parent.kind !== 228 /* InterfaceDeclaration */ && + n.parent.kind !== 227 /* ClassDeclaration */ && n.parent.kind !== 197 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { @@ -38770,7 +39139,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -38781,7 +39150,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 225 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { + if (node.kind === 226 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -38903,16 +39272,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -38924,7 +39293,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 /* Any */ | 8192 /* Never */)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -39175,7 +39545,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -39238,7 +39608,7 @@ var ts; checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -39271,6 +39641,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -39342,28 +39713,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261 /* SourceFile */: - case 230 /* ModuleDeclaration */: + case 262 /* SourceFile */: + case 231 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 205 /* Block */: + case 233 /* CaseBlock */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; case 150 /* Constructor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: @@ -39387,7 +39758,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -39420,9 +39791,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 212 /* ForInStatement */ || - declaration.parent.parent.kind === 213 /* ForOfStatement */)) { + if (declaration.kind === 224 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 213 /* ForInStatement */ || + declaration.parent.parent.kind === 214 /* ForOfStatement */)) { return; } } @@ -39485,7 +39856,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -39494,7 +39865,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 204 /* Block */) { + if (node.kind === 205 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -39542,6 +39913,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; @@ -39559,6 +39935,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 70 /* Identifier */; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -39570,8 +39962,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70 /* Identifier */; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70 /* Identifier */; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -39588,12 +39980,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39603,12 +39995,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39643,7 +40035,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 223 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 224 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -39653,17 +40045,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 205 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 206 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 204 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 231 /* ModuleBlock */ || - container.kind === 230 /* ModuleDeclaration */ || - container.kind === 261 /* SourceFile */); + (container.kind === 205 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 232 /* ModuleBlock */ || + container.kind === 231 /* ModuleDeclaration */ || + container.kind === 262 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -39708,7 +40100,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 /* Parameter */) { + if (symbol.valueDeclaration.kind === 144 /* Parameter */ || + symbol.valueDeclaration.kind === 174 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -39756,7 +40149,7 @@ var ts; } } if (node.kind === 174 /* BindingElement */) { - if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { + if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -39764,13 +40157,13 @@ var ts; checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_24 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -39785,7 +40178,7 @@ var ts; // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39796,7 +40189,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39819,18 +40212,19 @@ var ts; if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { + if (node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 /* Parameter */ && right.kind === 223 /* VariableDeclaration */) || - (left.kind === 223 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { + if ((left.kind === 144 /* Parameter */ && right.kind === 224 /* VariableDeclaration */) || + (left.kind === 224 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -39881,7 +40275,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206 /* EmptyStatement */) { + if (node.thenStatement.kind === 207 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -39901,12 +40295,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 225 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -39929,7 +40323,7 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { @@ -39968,7 +40362,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -40318,7 +40712,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 254 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 255 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -40330,7 +40724,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 254 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable @@ -40361,7 +40755,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 220 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -40501,7 +40895,7 @@ var ts; /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -40522,7 +40916,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ || declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 227 /* ClassDeclaration */ || declaration.kind === 228 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -40555,6 +40949,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -40590,7 +40985,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 227 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -40751,7 +41146,7 @@ var ts; // TypeScript 1.0 spec (April 2014): // When a generic interface has multiple declarations, all declarations must have identical type parameter // lists, i.e. identical type parameter names with identical constraints in identical order. - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -40811,7 +41206,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -40953,6 +41348,7 @@ var ts; } return undefined; case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(e); return +e.text; case 183 /* ParenthesizedExpression */: return evalConstant(e.expression); @@ -41033,6 +41429,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -41061,7 +41458,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 229 /* EnumDeclaration */) { + if (declaration.kind !== 230 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -41084,8 +41481,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 /* ClassDeclaration */ || - (declaration.kind === 225 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 /* ClassDeclaration */ || + (declaration.kind === 226 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -41149,7 +41546,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 226 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 227 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -41200,23 +41597,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 241 /* ExportAssignment */: + case 242 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: var name_25 = node.name; if (ts.isBindingPattern(name_25)) { for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { @@ -41227,12 +41624,12 @@ var ts; break; } // fallthrough - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 225 /* FunctionDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 226 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -41273,9 +41670,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -41308,7 +41705,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 /* ExportSpecifier */ ? + var message = node.kind === 244 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -41336,7 +41733,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -41393,8 +41790,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -41408,7 +41805,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 /* SourceFile */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 230 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 262 /* SourceFile */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 231 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -41434,9 +41831,14 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 261 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 230 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 231 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } // Grammar checking @@ -41510,7 +41912,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || + return (declaration.kind !== 226 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || !!declaration.body; } } @@ -41523,10 +41925,10 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -41575,71 +41977,71 @@ var ts; return checkIndexedAccessType(node); case 170 /* MappedType */: return checkMappedType(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return checkBlock(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return checkVariableStatement(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return checkExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return checkIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return checkDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return checkWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return checkForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return checkForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return checkForOfStatement(node); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return checkReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return checkWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return checkSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return checkLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return checkThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return checkTryStatement(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return checkVariableDeclaration(node); case 174 /* BindingElement */: return checkBindingElement(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return checkClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return checkImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return checkExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return checkExportAssignment(node); - case 206 /* EmptyStatement */: + case 207 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -41696,6 +42098,7 @@ var ts; // Grammar checking checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -41715,6 +42118,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1 /* TypeChecked */; } } @@ -41772,7 +42179,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 218 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -41795,14 +42202,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; case 197 /* ClassExpression */: @@ -41812,8 +42219,8 @@ var ts; } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -41872,10 +42279,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143 /* TypeParameter */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: return true; } } @@ -41885,7 +42292,7 @@ var ts; while (node.parent && node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 272 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 273 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -41912,10 +42319,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 235 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 241 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -41939,13 +42346,13 @@ var ts; default: } } - if (entityName.parent.kind === 240 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } if (entityName.kind !== 177 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 234 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 235 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -41995,10 +42402,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 272 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 273 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 250 /* JsxAttribute */) { + else if (entityName.parent.kind === 251 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156 /* TypePredicate */) { @@ -42008,7 +42415,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -42066,7 +42473,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 /* ImportDeclaration */ || node.parent.kind === 241 /* ExportDeclaration */) && + ((node.parent.kind === 236 /* ImportDeclaration */ || node.parent.kind === 242 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -42093,7 +42500,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 258 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 259 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -42159,7 +42566,7 @@ var ts; // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 213 /* ForOfStatement */) { + if (expr.parent.kind === 214 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -42171,7 +42578,7 @@ var ts; } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 257 /* PropertyAssignment */) { + if (expr.parent.kind === 258 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -42312,7 +42719,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 261 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 262 /* SourceFile */) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -42369,7 +42776,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 204 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 205 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -42415,16 +42822,16 @@ var ts; return true; } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -42434,7 +42841,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -42500,7 +42907,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260 /* EnumMember */) { + if (node.kind === 261 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -42601,9 +43008,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -42732,15 +43139,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -42760,7 +43167,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 262 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -42946,7 +43353,7 @@ var ts; } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 229 /* EnumDeclaration */ && node.parent.kind === 226 /* ClassDeclaration */) { + if (node.kind !== 230 /* EnumDeclaration */ && node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -42972,7 +43379,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -42995,7 +43402,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144 /* Parameter */) { @@ -43031,7 +43438,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144 /* Parameter */) { @@ -43046,13 +43453,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -43062,14 +43469,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226 /* ClassDeclaration */) { + if (node.kind !== 227 /* ClassDeclaration */) { if (node.kind !== 149 /* MethodDeclaration */ && node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 151 /* GetAccessor */ && node.kind !== 152 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 227 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -43111,7 +43518,7 @@ var ts; } return; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -43145,29 +43552,29 @@ var ts; case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 155 /* IndexSignature */: - case 230 /* ModuleDeclaration */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: + case 231 /* ModuleDeclaration */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: + case 241 /* ExportAssignment */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 144 /* Parameter */: return false; default: - if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return false; } switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 227 /* InterfaceDeclaration */: - case 205 /* VariableStatement */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 206 /* VariableStatement */: + case 229 /* TypeAliasDeclaration */: return true; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -43181,7 +43588,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149 /* MethodDeclaration */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: if (!node.asteriskToken) { @@ -43392,7 +43799,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 /* FunctionDeclaration */ || + ts.Debug.assert(node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || node.kind === 149 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { @@ -43419,7 +43826,7 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */) { + if (prop.kind === 260 /* SpreadAssignment */) { continue; } var name_28 = prop.name; @@ -43427,7 +43834,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_28); } - if (prop.kind === 258 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -43450,7 +43857,7 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */) { + if (prop.kind === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_28.kind === 8 /* NumericLiteral */) { @@ -43500,7 +43907,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251 /* JsxSpreadAttribute */) { + if (attr.kind === 252 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -43512,7 +43919,7 @@ var ts; return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 253 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -43521,7 +43928,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -43536,20 +43943,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -43642,7 +44049,7 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 228 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } else if (node.parent.kind === 161 /* TypeLiteral */) { @@ -43656,11 +44063,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 214 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 215 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -43668,8 +44075,8 @@ var ts; return false; } break; - case 218 /* SwitchStatement */: - if (node.kind === 215 /* BreakStatement */ && !node.label) { + case 219 /* SwitchStatement */: + if (node.kind === 216 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -43684,13 +44091,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 /* BreakStatement */ + var message = node.kind === 216 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 215 /* BreakStatement */ + var message = node.kind === 216 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -43717,7 +44124,7 @@ var ts; expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 /* ForInStatement */ && node.parent.parent.kind !== 213 /* ForOfStatement */) { + if (node.parent.parent.kind !== 213 /* ForInStatement */ && node.parent.parent.kind !== 214 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -43782,15 +44189,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return false; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -43805,6 +44212,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -43845,7 +44259,7 @@ var ts; return true; } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 228 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -43878,13 +44292,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 227 /* InterfaceDeclaration */ || - node.kind === 228 /* TypeAliasDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 241 /* ExportDeclaration */ || - node.kind === 240 /* ExportAssignment */ || - node.kind === 233 /* NamespaceExportDeclaration */ || + if (node.kind === 228 /* InterfaceDeclaration */ || + node.kind === 229 /* TypeAliasDeclaration */ || + node.kind === 236 /* ImportDeclaration */ || + node.kind === 235 /* ImportEqualsDeclaration */ || + node.kind === 242 /* ExportDeclaration */ || + node.kind === 241 /* ExportAssignment */ || + node.kind === 234 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -43893,7 +44307,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 205 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 206 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -43919,7 +44333,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 204 /* Block */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 205 /* Block */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -43932,8 +44346,22 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.isOctalLiteral && languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1 /* ES5 */) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171 /* LiteralType */)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261 /* EnumMember */)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37 /* MinusToken */; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -43997,31 +44425,31 @@ var ts; _a[201 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229 /* EnumDeclaration */] = [ + _a[230 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230 /* ModuleDeclaration */] = [ + _a[231 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231 /* ModuleBlock */] = [ + _a[232 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[234 /* ImportEqualsDeclaration */] = [ + _a[235 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245 /* ExternalModuleReference */] = [ + _a[246 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260 /* EnumMember */] = [ + _a[261 /* EnumMember */] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -44059,11 +44487,11 @@ var ts; var result = initial; switch (node.kind) { // Leaf nodes - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: + case 204 /* SemicolonClassElement */: + case 207 /* EmptyStatement */: case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: - case 293 /* NotEmittedStatement */: + case 223 /* DebuggerStatement */: + case 294 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -44211,73 +44639,73 @@ var ts; result = reduceNodes(node.typeArguments, cbNodes, result); break; // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 204 /* Block */: + case 205 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 208 /* IfStatement */: + case 209 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209 /* DoStatement */: + case 210 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 210 /* WhileStatement */: - case 217 /* WithStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 211 /* ForStatement */: + case 212 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 221 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221 /* TryStatement */: + case 222 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44286,7 +44714,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44294,97 +44722,97 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236 /* ImportClause */: + case 237 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // fall-through - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 256 /* CatchClause */: + case 257 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; default: @@ -44542,10 +44970,10 @@ var ts; return node; } switch (node.kind) { - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: + case 204 /* SemicolonClassElement */: + case 207 /* EmptyStatement */: case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names @@ -44620,107 +45048,107 @@ var ts; case 199 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 204 /* Block */: + case 205 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 238 /* NamedImports */: + case 239 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 242 /* NamedExports */: + case 243 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -44836,7 +45264,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 199 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -45412,15 +45840,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 231 /* ModuleBlock */: - case 204 /* Block */: + case 262 /* SourceFile */: + case 233 /* CaseBlock */: + case 232 /* ModuleBlock */: + case 205 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226 /* ClassDeclaration */: - case 225 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: + case 226 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -45467,13 +45895,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -45493,11 +45921,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 241 /* ExportDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 236 /* ImportClause */ || - (node.kind === 234 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 245 /* ExternalModuleReference */)) { + if (node.kind === 242 /* ExportDeclaration */ || + node.kind === 236 /* ImportDeclaration */ || + node.kind === 237 /* ImportClause */ || + (node.kind === 235 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 246 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -45539,7 +45967,7 @@ var ts; case 149 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -45608,18 +46036,18 @@ var ts; // TypeScript index signatures are elided. case 145 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. case 147 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; case 150 /* Constructor */: return visitConstructor(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -45641,7 +46069,7 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: @@ -45660,7 +46088,7 @@ var ts; case 152 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: @@ -45694,18 +46122,18 @@ var ts; case 201 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -46113,7 +46541,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -46622,7 +47050,7 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 149 /* MethodDeclaration */: @@ -46645,7 +47073,7 @@ var ts; return serializeTypeNode(node.type); case 152 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: case 149 /* MethodDeclaration */: return ts.createIdentifier("Function"); @@ -46730,6 +47158,9 @@ var ts; } switch (node.kind) { case 104 /* VoidKeyword */: + case 137 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 129 /* NeverKeyword */: return ts.createVoidZero(); case 166 /* ParenthesizedType */: return serializeTypeNode(node.type); @@ -46768,34 +47199,7 @@ var ts; return serializeTypeReferenceNode(node); case 165 /* IntersectionType */: case 164 /* UnionType */: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - // Non identifier - if (serializedIndividual.kind !== 70 /* Identifier */) { - serializedUnion = undefined; - break; - } - // One of the individual is global object, return immediately - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - // Different types - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - // If we were able to find common type - if (serializedUnion) { - return serializedUnion; - } - } - // Fallthrough + return serializeUnionOrIntersectionType(node); case 160 /* TypeQuery */: case 168 /* TypeOperator */: case 169 /* IndexedAccessType */: @@ -46810,6 +47214,37 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + // If we dont have any other type already set, set the initial type + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + // One of the individual is global object, return immediately + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + // Different types + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + // Initialize the union type + serializedUnion = serializedIndividual; + } + } + // If we were able to find common type, use it + return serializedUnion; + } /** * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with * decorator type metadata. @@ -47411,7 +47846,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 229 /* EnumDeclaration */) { + if (node.kind === 230 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -47530,8 +47965,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231 /* ModuleBlock */) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232 /* ModuleBlock */) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -47576,13 +48011,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 231 /* ModuleBlock */) { + if (body.kind !== 232 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -47623,7 +48058,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 237 /* NamespaceImport */) { + if (node.kind === 238 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -47855,16 +48290,16 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); + context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(230 /* ModuleDeclaration */); + context.enableEmitNotification(231 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 231 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 230 /* EnumDeclaration */; } /** * Hook for node emit. @@ -47960,9 +48395,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 261 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 230 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 229 /* EnumDeclaration */); + if (container && container.kind !== 262 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 231 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 230 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -48082,11 +48517,11 @@ var ts; return visitObjectLiteralExpression(node); case 192 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitForOfStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); case 188 /* VoidExpression */: return visitVoidExpression(node); @@ -48098,7 +48533,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); @@ -48106,7 +48541,7 @@ var ts; return visitArrowFunction(node); case 144 /* Parameter */: return visitParameter(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return visitExpressionStatement(node); case 183 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); @@ -48119,7 +48554,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259 /* SpreadAssignment */) { + if (e.kind === 260 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -48131,7 +48566,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257 /* PropertyAssignment */) { + if (e.kind === 258 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -48361,11 +48796,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48375,11 +48810,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return visitJsxExpression(node); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -48440,7 +48875,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; } - else if (node.kind === 252 /* JsxExpression */) { + else if (node.kind === 253 /* JsxExpression */) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -48522,7 +48960,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246 /* JsxElement */) { + if (node.kind === 247 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -48868,7 +49306,7 @@ var ts; case 149 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: @@ -49032,7 +49470,7 @@ var ts; context.enableSubstitution(177 /* PropertyAccessExpression */); context.enableSubstitution(178 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(226 /* ClassDeclaration */); + context.enableEmitNotification(227 /* ClassDeclaration */); context.enableEmitNotification(149 /* MethodDeclaration */); context.enableEmitNotification(151 /* GetAccessor */); context.enableEmitNotification(152 /* SetAccessor */); @@ -49089,7 +49527,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 /* ClassDeclaration */ + return kind === 227 /* ClassDeclaration */ || kind === 150 /* Constructor */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ @@ -49299,6 +49737,82 @@ var ts; */ SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; })(SuperCaptureResult || (SuperCaptureResult = {})); + // Facts we track as we traverse the tree + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + // + // Ancestor facts + // + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + // + // Ancestor masks + // + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + // We are always in *some* kind of block scope, but only specific block-scope containers are + // top-level or Blocks. + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + // A source file is a top-level block scope. + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + // Functions, methods, and accessors are both new lexical scopes and new block scopes. + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + // Arrow functions are lexically scoped to their container, but are new block scopes. + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + // Constructors are both new lexical scopes and new block scopes. Constructors are also + // always considered non-static members of a class. + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + // 'do' and 'while' statements are not block scopes. We track that the subtree is contained + // within an IterationStatement to indicate whether the embedded statement is an + // IterationStatementBlock. + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + // 'for' statements are new block scopes and have special handling for 'let' declarations. + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + // 'for-in' and 'for-of' statements are new block scopes and have special handling for + // 'let' declarations. + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + // Blocks (other than function bodies) are new block scopes. + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + // Computed property names track subtree flags differently than their containing members. + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + // + // Subtree facts + // + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + // + // Subtree masks + // + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -49308,15 +49822,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; /** * Used to track if we are emitting body of the converted loop */ @@ -49334,185 +49840,116 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0 /* None */; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + **/ + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072 /* AsyncFunctionBody */)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case 205 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 224 /* VariableDeclarationList */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree, propagating specific facts from the subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. + * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. + **/ + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 /* ReturnStatement */ && !node.expression; + return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ + && node.kind === 217 /* ReturnStatement */ + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES2015 */) !== 0 || - node.kind === 219 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && ts.isStatement(node)) + || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - // we want to dive in this branch either if node has children with ES2015 specific syntax - // or we are inside constructor that captures result of the super call so all returns without expression should be - // rewritten. Note: we skip expressions since returns should never appear there - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, /*isFunctionBody*/ true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216 /* ReturnStatement */: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205 /* VariableStatement */: - return visitVariableStatement(node); - case 218 /* SwitchStatement */: - return visitSwitchStatement(node); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 98 /* ThisKeyword */: - return visitThisKeyword(node); - case 70 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96 /* SuperKeyword */) { + return visitSuperKeyword(/*isExpressionOfCall*/ true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114 /* StaticKeyword */: return undefined; // elide static keyword - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); case 197 /* ClassExpression */: return visitClassExpression(node); case 144 /* Parameter */: return visitParameter(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 185 /* ArrowFunction */: return visitArrowFunction(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 219 /* LabeledStatement */: + case 219 /* SwitchStatement */: + return visitSwitchStatement(node); + case 233 /* CaseBlock */: + return visitCaseBlock(node); + case 205 /* Block */: + return visitBlock(node, /*isFunctionBody*/ false); + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 220 /* LabeledStatement */: return visitLabeledStatement(node); - case 209 /* DoStatement */: - return visitDoStatement(node); - case 210 /* WhileStatement */: - return visitWhileStatement(node); - case 211 /* ForStatement */: - return visitForStatement(node); - case 212 /* ForInStatement */: - return visitForInStatement(node); - case 213 /* ForOfStatement */: - return visitForOfStatement(node); - case 207 /* ExpressionStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); + case 212 /* ForStatement */: + return visitForStatement(node, /*outermostLabeledStatement*/ undefined); + case 213 /* ForInStatement */: + return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); + case 214 /* ForOfStatement */: + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); + case 208 /* ExpressionStatement */: return visitExpressionStatement(node); case 176 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitCatchClause(node); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); + case 142 /* ComputedPropertyName */: + return visitComputedPropertyName(node); case 175 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); case 179 /* CallExpression */: @@ -49537,54 +49974,82 @@ var ts; case 196 /* SpreadElement */: return visitSpreadElement(node); case 96 /* SuperKeyword */: - return visitSuperKeyword(); - case 195 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(/*isExpressionOfCall*/ false); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 202 /* MetaProperty */: + return visitMetaProperty(node); case 149 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 205 /* VariableStatement */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return visitAccessorDeclaration(node); + case 206 /* VariableStatement */: return visitVariableStatement(node); + case 217 /* ReturnStatement */: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8 /* Return */; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8 /* Return */; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -49604,13 +50069,13 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 215 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 216 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 216 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -49621,7 +50086,7 @@ var ts; } } else { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 216 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -49813,6 +50278,9 @@ var ts; * @param extendsClauseElement The expression for the class `extends` clause. */ function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration( @@ -49826,6 +50294,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; } /** * Transforms the parameters of the constructor declaration of a class. @@ -49871,26 +50341,31 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // determine whether the class is known syntactically to be a derived class (e.g. a + // class that extends a value that is not syntactically known to be `null`). + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94 /* NullKeyword */; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1 /* ReplaceSuperCapture */; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1 /* ReplaceSuperCapture */) { + hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset)); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 /* ReplaceWithReturn */ && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); + } var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ constructor ? constructor.body.statements : node.members), /*location*/ constructor ? constructor.body : node, @@ -49907,17 +50382,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 216 /* ReturnStatement */) { + if (statement.kind === 217 /* ReturnStatement */) { return true; } - else if (statement.kind === 208 /* IfStatement */) { + else if (statement.kind === 209 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204 /* Block */) { + else if (statement.kind === 205 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -49930,9 +50405,9 @@ var ts; * * @returns The new statement offset into the `statements` array. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -49975,9 +50450,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } // Return the result if we have an immediate super() call on the last statement, @@ -49996,18 +50470,18 @@ var ts; return 2 /* ReplaceWithReturn */; } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { return 1 /* ReplaceSuperCapture */; } return 0 /* NoReplacement */; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -50202,6 +50676,46 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384 /* NewTarget */) { + var newTarget = void 0; + switch (node.kind) { + case 185 /* ArrowFunction */: + return statements; + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + // Methods and accessors cannot be constructors, so 'new.target' will + // always return 'undefined'. + newTarget = ts.createVoidZero(); + break; + case 150 /* Constructor */: + // Class constructors can only be called with `new`, so `this.constructor` + // should be relatively safe to use. + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); + break; + case 226 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + // Functions can be called or constructed, and may have a `this` due to + // being a member or when calling an imported function via `other_1.f()`. + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", + /*type*/ undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -50213,17 +50727,17 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151 /* GetAccessor */: case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150 /* Constructor */: @@ -50249,11 +50763,12 @@ var ts; * @param receiver The receiver for the member. * @param member The MethodDeclaration node. */ - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), @@ -50264,6 +50779,7 @@ var ts; // No source map should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 48 /* NoSourceMap */); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return statement; } /** @@ -50272,8 +50788,8 @@ var ts; * @param receiver The receiver for the member. * @param accessors The set of related get/set accessors. */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false), /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the @@ -50287,8 +50803,9 @@ var ts; * * @param receiver The receiver for the member. */ - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); @@ -50299,7 +50816,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -50307,7 +50824,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -50324,6 +50841,7 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return call; } /** @@ -50335,6 +50853,9 @@ var ts; if (node.transformFlags & 16384 /* ContainsLexicalThis */) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); var func = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -50343,6 +50864,8 @@ var ts; /*type*/ undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; return func; } /** @@ -50351,12 +50874,24 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var ancestorFacts = ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */ + ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Visits a FunctionDeclaration node. @@ -50364,12 +50899,22 @@ var ts; * @param node a FunctionDeclaration node. */ function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, node.modifiers, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Transforms a function-like node into a FunctionExpression. @@ -50378,18 +50923,24 @@ var ts; * @param location The source-map location for the new FunctionExpression. * @param name The name of the new FunctionExpression. */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */) + ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression( + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body, location), /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** * Transforms the body of a function-like node. @@ -50451,6 +51002,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; @@ -50465,6 +51017,23 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true), + /*location*/ updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + // A function body is not a block scope. + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ + ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) + : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -50511,9 +51080,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { + var ancestorFacts = enterSubtree(0 /* None */, ts.hasModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -50531,14 +51103,18 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); } else { // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } /** * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). @@ -50546,25 +51122,28 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64 /* ES2015 */) { + if (node.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } /** * Gets a value indicating whether we should emit an explicit initializer for a variable @@ -50615,18 +51194,16 @@ var ts; var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 213 /* ForOfStatement */ + && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -50655,55 +51232,52 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. + var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, + /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: // // for (let v of expr) { } @@ -50815,7 +51389,20 @@ var ts; /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212 /* ForStatement */: + return visitForStatement(node, outermostLabeledStatement); + case 213 /* ForInStatement */: + return visitForInStatement(node, outermostLabeledStatement); + case 214 /* ForOfStatement */: + return visitForOfStatement(node, outermostLabeledStatement); + } } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -50829,31 +51416,40 @@ var ts; // Find the first computed property. // Everything until that point can be emitted as part of the initial object literal. var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 /* ContainsYield */ - || property.name.kind === 142 /* ComputedPropertyName */) { + if ((property.transformFlags & 16777216 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142 /* ComputedPropertyName */) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 32768 /* Indented */)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), + /*location*/ undefined, node.multiLine), 32768 /* Indented */)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; @@ -50880,7 +51476,7 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { @@ -50889,7 +51485,9 @@ var ts; saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -50898,11 +51496,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 225 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -50939,7 +51537,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -50951,11 +51549,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, /*location*/ undefined, /*multiline*/ true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072 /* AsyncFunctionBody */) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -51038,25 +51638,24 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); + var clone_4 = ts.getMutableClone(node); // clean statement part - loop.statement = undefined; + clone_4.statement = undefined; // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); + clone_4 = ts.visitEachChild(clone_4, visitor, context); // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, /*location*/ undefined, /*multiline*/ true); // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -51186,18 +51785,18 @@ var ts; case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257 /* PropertyAssignment */: + case 149 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 258 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -51241,22 +51840,32 @@ var ts; * @param method The MethodDeclaration node. * @param receiver The receiver for the assignment. */ - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container), /*location*/ method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); - var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -51273,11 +51882,26 @@ var ts; // Methods on classes are handled in visitClassDeclaration/visitClassExpression. // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); + var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, /*location*/ node); } + /** + * Visits an AccessorDeclaration of an ObjectLiteralExpression. + * + * @param node An AccessorDeclaration node. + */ + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return updated; + } /** * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. * @@ -51287,6 +51911,12 @@ var ts; return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), /*location*/ node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0 /* ComputedPropertyNameExcludes */, 8192 /* ComputedPropertyNameIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 32768 /* NewTargetInComputedPropertyName */ : 0 /* None */); + return updated; + } /** * Visits a YieldExpression node. * @@ -51302,8 +51932,11 @@ var ts; * @param node An ArrayLiteralExpression node. */ function visitArrayLiteralExpression(node) { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + if (node.transformFlags & 64 /* ES2015 */) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } /** * Visits a CallExpression that contains either a spread element or `super`. @@ -51311,7 +51944,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + if (node.transformFlags & 64 /* ES2015 */) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); @@ -51338,7 +51975,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -51350,18 +51987,18 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } if (node.expression.kind === 96 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } /** * Visits a NewExpression that contains a spread element. @@ -51369,16 +52006,18 @@ var ts; * @param node A NewExpression node. */ function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 524288 /* ContainsSpread */) !== 0); - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), - /*typeArguments*/ undefined, []); + if (node.transformFlags & 524288 /* ContainsSpread */) { + // We are here because we contain a SpreadElementExpression. + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + /*typeArguments*/ undefined, []); + } + return ts.visitEachChild(node, visitor, context); } /** * Transforms an array of Expression nodes that contains a SpreadExpression. @@ -51581,27 +52220,40 @@ var ts; /** * Visits the `super` keyword */ - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 179 /* CallExpression */ + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 /* NonStaticClassElement */ + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target") { + if (hierarchyFacts & 8192 /* ComputedPropertyName */) { + hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; + } + else { + hierarchyFacts |= 16384 /* NewTarget */; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } /** * Called by the printer just before a node is printed. * * @param node The node to be printed. */ function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ + ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ + : 65 /* FunctionIncludes */); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } /** * Enables a more costly code path for substitutions when we determine a source file @@ -51627,7 +52279,7 @@ var ts; context.enableEmitNotification(152 /* SetAccessor */); context.enableEmitNotification(185 /* ArrowFunction */); context.enableEmitNotification(184 /* FunctionExpression */); - context.enableEmitNotification(225 /* FunctionDeclaration */); + context.enableEmitNotification(226 /* FunctionDeclaration */); } } /** @@ -51670,9 +52322,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 223 /* VariableDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 224 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -51713,8 +52365,7 @@ var ts; */ function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8 /* CapturesThis */) { + && hierarchyFacts & 16 /* CapturesThis */) { return ts.createIdentifier("_this", /*location*/ node); } return node; @@ -51731,7 +52382,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; @@ -51763,7 +52414,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); /// @@ -52036,13 +52687,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitWhileStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -52055,24 +52706,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); case 151 /* GetAccessor */: case 152 /* SetAccessor */: return visitAccessorDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitForInStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return visitBreakStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return visitContinueStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -52120,7 +52771,7 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); @@ -52405,10 +53056,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -52553,7 +53204,7 @@ var ts; emitYield(expression, /*location*/ node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(/*location*/ node); } /** * Visits an ArrayLiteralExpression that contains a YieldExpression. @@ -52667,10 +53318,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -52737,35 +53388,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204 /* Block */: + case 205 /* Block */: return transformAndEmitBlock(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return transformAndEmitIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return transformAndEmitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return transformAndEmitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return transformAndEmitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -52785,7 +53436,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_37 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_37, variable.name); + hoistVariableDeclaration(name_37); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -52828,7 +53481,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -53185,7 +53838,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 255 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -53198,7 +53851,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 254 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -53359,12 +54012,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_38) { + var clone_7 = ts.getMutableClone(name_38); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -54249,9 +54902,9 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation)); + : [createInstruction(2 /* Return */)]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -54261,10 +54914,10 @@ var ts; */ function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -54274,10 +54927,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -54287,10 +54940,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -54300,9 +54953,9 @@ var ts; */ function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation)); + : [createInstruction(4 /* Yield */)]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -54312,10 +54965,10 @@ var ts; */ function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5 /* YieldStar */), expression - ]), operationLocation)); + ]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -54411,10 +55064,22 @@ var ts; * @param context Context and state information for the transformation. */ function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + // enable emit notification only if using --jsx preserve + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 /* Preserve */) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249 /* JsxOpeningElement */); + context.enableEmitNotification(250 /* JsxClosingElement */); + context.enableEmitNotification(248 /* JsxSelfClosingElement */); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(257 /* PropertyAssignment */); + context.enableSubstitution(258 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -54424,6 +55089,22 @@ var ts; function transformSourceFile(node) { return node; } + /** + * Called by the printer just before a node is printed. + * + * @param node The node to be printed. + */ + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249 /* JsxOpeningElement */: + case 250 /* JsxClosingElement */: + case 248 /* JsxSelfClosingElement */: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } /** * Hooks node substitutions. * @@ -54431,6 +55112,9 @@ var ts; * @param node The node to substitute. */ function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -54490,7 +55174,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261 /* SourceFile */); + context.enableEmitNotification(262 /* SourceFile */); context.enableSubstitution(70 /* Identifier */); var currentSourceFile; return transformSourceFile; @@ -54517,10 +55201,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -54595,7 +55279,7 @@ var ts; context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. @@ -54815,7 +55499,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 242 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -54840,7 +55524,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241 /* ExportDeclaration */) { + if (externalImport.kind !== 242 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -54921,19 +55605,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -54983,15 +55667,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -55169,7 +55853,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 261 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 262 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -55233,7 +55917,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -55289,10 +55973,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 239 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -55471,43 +56155,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitForOfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitWhileStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return visitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitSwitchStatement(node); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return visitCaseBlock(node); - case 253 /* CaseClause */: + case 254 /* CaseClause */: return visitCaseClause(node); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return visitDefaultClause(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return visitTryStatement(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitCatchClause(node); - case 204 /* Block */: + case 205 /* Block */: return visitBlock(node); - case 295 /* MergeDeclarationMarker */: + case 296 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 297 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -55735,7 +56419,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261 /* SourceFile */; + return container !== undefined && container.kind === 262 /* SourceFile */; } else { return false; @@ -55768,7 +56452,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -55941,7 +56625,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -55997,8 +56681,8 @@ var ts; context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -56052,26 +56736,6 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { // An AMD define function has the following shape: // // define(id?, dependencies?, factory); @@ -56092,7 +56756,7 @@ var ts; // /// // // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; // Create an updated SourceFile: // // define(moduleName?, ["module1", "module2"], function ... @@ -56122,6 +56786,73 @@ var ts; ], /*location*/ node.statements)); } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, [ + ts.createVariableDeclaration("v", + /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], + /*location*/ undefined, + /*multiLine*/ true)); + // Create an updated SourceFile: + // + // (function (factory) { + // if (typeof module === "object" && typeof module.exports === "object") { + // var v = factory(require, exports); + // if (v !== undefined) module.exports = v; + // } + // else if (typeof define === 'function' && define.amd) { + // define(["require", "exports"], factory); + // } + // })(function ...) + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, + /*typeArguments*/ undefined, [ + // Add the module body function argument: + // + // function (require, exports) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ])) + ], + /*location*/ node.statements)); + } /** * Collect the additional asynchronous dependencies for the module. * @@ -56226,23 +56957,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); - case 295 /* MergeDeclarationMarker */: + case 296 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 297 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: // This visitor does not descend into the tree, as export/import statements @@ -56554,7 +57285,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -56609,10 +57340,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 239 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -56811,7 +57542,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -56899,7 +57630,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), /*location*/ node); } @@ -56910,8 +57641,8 @@ var ts; /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), + var name_39 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), /*location*/ node); } } @@ -57013,8 +57744,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - // emit output for the UMD helper function. - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); /// /// @@ -57521,7 +58250,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 294 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -57534,7 +58263,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 294 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -57713,7 +58442,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 294 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -57732,7 +58461,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 225 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -58045,7 +58774,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 236 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -58120,10 +58849,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223 /* VariableDeclaration */) { + if (declaration.kind === 224 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 /* NamedImports */ || declaration.kind === 239 /* ImportSpecifier */ || declaration.kind === 236 /* ImportClause */) { + else if (declaration.kind === 239 /* NamedImports */ || declaration.kind === 240 /* ImportSpecifier */ || declaration.kind === 237 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -58141,7 +58870,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 236 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -58151,12 +58880,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -58334,7 +59063,7 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 234 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 235 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -58456,9 +59185,9 @@ var ts; var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } @@ -58505,10 +59234,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 /* ImportEqualsDeclaration */ || - (node.parent.kind === 261 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 235 /* ImportEqualsDeclaration */ || + (node.parent.kind === 262 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -58518,7 +59247,7 @@ var ts; }); } else { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -58536,23 +59265,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return writeVariableStatement(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return writeClassDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -58560,7 +59289,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 262 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -58569,7 +59298,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 227 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 228 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -58621,7 +59350,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 238 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -58645,7 +59374,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 238 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -58666,13 +59395,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 234 /* ImportEqualsDeclaration */) { + if (parent.kind === 235 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230 /* ModuleDeclaration */) { + else if (parent.kind === 231 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -58742,7 +59471,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231 /* ModuleBlock */) { + while (node.body && node.body.kind !== 232 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -58842,10 +59571,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154 /* ConstructSignature */: @@ -58859,17 +59588,17 @@ var ts; if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 227 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -58907,7 +59636,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + if (node.parent.parent.kind === 227 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -58994,7 +59723,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 223 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -59022,7 +59751,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59038,7 +59767,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59212,13 +59941,13 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 226 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 226 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } @@ -59323,7 +60052,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59337,7 +60066,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59420,7 +60149,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 227 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59433,7 +60162,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59509,20 +60238,20 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 227 /* InterfaceDeclaration */: - case 226 /* ClassDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 226 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 228 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return emitExportDeclaration(node); case 150 /* Constructor */: case 149 /* MethodDeclaration */: @@ -59538,11 +60267,11 @@ var ts; case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return emitPropertyDeclaration(node); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return emitExportAssignment(node); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return emitSourceFile(node); } } @@ -59835,7 +60564,7 @@ var ts; var kind = node.kind; switch (kind) { // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: return emitSourceFile(node); } } @@ -59983,126 +60712,126 @@ var ts; case 174 /* BindingElement */: return emitBindingElement(node); // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return emitTemplateSpan(node); - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 204 /* Block */: + case 205 /* Block */: return emitBlock(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return emitVariableStatement(node); - case 206 /* EmptyStatement */: + case 207 /* EmptyStatement */: return emitEmptyStatement(); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return emitExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return emitIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return emitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return emitWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return emitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return emitForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return emitForOfStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return emitContinueStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return emitBreakStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return emitReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return emitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return emitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return emitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return emitThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return emitTryStatement(node); - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return emitClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return emitModuleBlock(node); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return emitCaseBlock(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return emitImportDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return emitImportClause(node); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return emitNamespaceImport(node); - case 238 /* NamedImports */: + case 239 /* NamedImports */: return emitNamedImports(node); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return emitImportSpecifier(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return emitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return emitExportDeclaration(node); - case 242 /* NamedExports */: + case 243 /* NamedExports */: return emitNamedExports(node); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return emitExportSpecifier(node); - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return; // Module references - case 245 /* ExternalModuleReference */: + case 246 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return emitJsxAttribute(node); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: return emitCaseClause(node); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return emitDefaultClause(node); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return emitHeritageClause(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 260 /* EnumMember */: + case 261 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -60191,16 +60920,16 @@ var ts; return emitAsExpression(node); case 201 /* NonNullExpression */: return emitNonNullExpression(node); + case 202 /* MetaProperty */: + return emitMetaProperty(node); // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: return emitJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 297 /* RawExpression */: - return writeLines(node.text); } } // @@ -60693,6 +61422,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } // // Misc // @@ -60741,27 +61475,27 @@ var ts; writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 208 /* IfStatement */) { + if (node.elseStatement.kind === 209 /* IfStatement */) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -60771,7 +61505,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60783,7 +61517,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60793,7 +61527,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60803,11 +61537,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 225 /* VariableDeclarationList */) { emit(node); } else { @@ -60834,7 +61568,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); @@ -60858,9 +61592,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -61046,7 +61783,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230 /* ModuleDeclaration */) { + while (body.kind === 231 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -61203,6 +61940,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -61438,8 +62178,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { write(" "); emit(node); } @@ -61580,6 +62320,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1 /* SingleLine */) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -61771,10 +62519,10 @@ var ts; */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_40 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name_41 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_40; + return name_41; } } while (true) { @@ -61782,11 +62530,11 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -61826,6 +62574,12 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0 /* Auto */); + } /** * Generates a unique name from a node. * @@ -61835,18 +62589,22 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 235 /* ImportDeclaration */: - case 241 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: + case 242 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: - case 240 /* ExportAssignment */: + case 226 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: + case 241 /* ExportAssignment */: return generateNameForExportDefault(); case 197 /* ClassExpression */: return generateNameForClassExpression(); + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); } @@ -61890,6 +62648,10 @@ var ts; // otherwise, return the original node for the source; return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } /** * Gets the generated identifier text from a generated identifier. * @@ -61900,8 +62662,7 @@ var ts; // Generated names generate unique names based on their original node // and are cached based on that node's id var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { // Auto, Loop, and Unique names are cached based on their unique @@ -62046,7 +62807,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { // Failed to find any common path component @@ -62237,10 +62999,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name_43 = names_1[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -62276,6 +63038,7 @@ var ts; var supportedExtensions = ts.getSupportedExtensions(options); // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -62289,7 +63052,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -62335,6 +63099,8 @@ var ts; } } } + // unconditionally set moduleResolutionCache to undefined to avoid unnecessary leaks + moduleResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; program = { @@ -62600,7 +63366,7 @@ var ts; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } // update fileName -> file mapping - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -62787,10 +63553,10 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 223 /* VariableDeclaration */: + case 226 /* FunctionDeclaration */: + case 224 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -62798,32 +63564,32 @@ var ts; } } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182 /* TypeAssertionExpression */: @@ -62841,26 +63607,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // pass through - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 206 /* VariableStatement */); } break; case 147 /* PropertyDeclaration */: @@ -62983,7 +63749,7 @@ var ts; // synthesize 'import "tslib"' declaration var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235 /* ImportDeclaration */); + var importDecl = ts.createSynthesizedNode(236 /* ImportDeclaration */); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -63001,9 +63767,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -63018,7 +63784,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -64281,11 +65047,11 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_43) { + switch (name_44) { case "init": case "watch": case "version": @@ -64293,14 +65059,14 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_43] = value; + result[name_44] = value; } else { if (optionDefinition.type === "list") { @@ -64309,11 +65075,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name_44] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -64361,6 +65127,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -65130,32 +65897,32 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 144 /* Parameter */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: - case 260 /* EnumMember */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: + case 261 /* EnumMember */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 256 /* CatchClause */: + case 257 /* CatchClause */: return 1 /* Value */; case 143 /* TypeParameter */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: case 161 /* TypeLiteral */: return 2 /* Type */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -65165,22 +65932,22 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* NamedImports */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 239 /* NamedImports */: + case 240 /* ImportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportDeclaration */: + case 241 /* ExportAssignment */: + case 242 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 261 /* SourceFile */: + case 262 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent.kind === 241 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -65207,7 +65974,7 @@ var ts; // import a = |b.c|.d; // Namespace if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 234 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 235 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; @@ -65241,10 +66008,10 @@ var ts; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 255 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 256 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 226 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 227 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 227 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 228 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -65275,7 +66042,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 220 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -65285,13 +66052,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 215 /* BreakStatement */ || node.parent.kind === 214 /* ContinueStatement */) && + (node.parent.kind === 216 /* BreakStatement */ || node.parent.kind === 215 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 219 /* LabeledStatement */ && + node.parent.kind === 220 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -65307,7 +66074,7 @@ var ts; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 231 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -65320,13 +66087,13 @@ var ts; switch (node.parent.kind) { case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 260 /* EnumMember */: + case 258 /* PropertyAssignment */: + case 261 /* EnumMember */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return node.parent.name === node; case 178 /* ElementAccessExpression */: return node.parent.argumentExpression === node; @@ -65379,17 +66146,17 @@ var ts; return undefined; } switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return node; } } @@ -65397,22 +66164,22 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 227 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 228 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 229 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 223 /* VariableDeclaration */: + case 228 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 229 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 230 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 224 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); case 174 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; @@ -65428,15 +66195,15 @@ var ts; case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 260 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 261 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234 /* ImportEqualsDeclaration */: - case 239 /* ImportSpecifier */: - case 236 /* ImportClause */: - case 243 /* ExportSpecifier */: - case 237 /* NamespaceImport */: + case 235 /* ImportEqualsDeclaration */: + case 240 /* ImportSpecifier */: + case 237 /* ImportClause */: + case 244 /* ExportSpecifier */: + case 238 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -65511,19 +66278,19 @@ var ts; return false; } switch (n.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: case 172 /* ObjectBindingPattern */: case 161 /* TypeLiteral */: - case 204 /* Block */: - case 231 /* ModuleBlock */: - case 232 /* CaseBlock */: - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 205 /* Block */: + case 232 /* ModuleBlock */: + case 233 /* CaseBlock */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return isCompletedNode(n.block, sourceFile); case 180 /* NewExpression */: if (!n.arguments) { @@ -65540,7 +66307,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -65556,14 +66323,14 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 208 /* IfStatement */: + case 209 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); case 175 /* ArrayLiteralExpression */: @@ -65577,16 +66344,16 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 209 /* DoStatement */: + case 210 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { @@ -65607,10 +66374,10 @@ var ts; case 194 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 241 /* ExportDeclaration */: - case 235 /* ImportDeclaration */: + case 242 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); case 190 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); @@ -65672,7 +66439,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 292 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 293 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -65739,8 +66506,8 @@ var ts; } } // find the child that contains 'position' - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; // all jsDocComment nodes were already visited if (ts.isJSDocNode(child)) { continue; @@ -65819,7 +66586,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; // condition 'position < child.end' checks if child node end after the position // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' @@ -65844,7 +66611,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 262 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -65903,17 +66670,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 253 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 253 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 249 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 250 /* JsxClosingElement */) { return true; } return false; @@ -66028,7 +66795,7 @@ var ts; if (node.kind === 157 /* TypeReference */ || node.kind === 179 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 /* ClassDeclaration */ || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 227 /* ClassDeclaration */ || node.kind === 228 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -66105,7 +66872,7 @@ var ts; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 213 /* ForOfStatement */ && + if (node.parent.kind === 214 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -66113,7 +66880,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -66339,7 +67106,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 /* ImportSpecifier */ || location.parent.kind === 243 /* ExportSpecifier */) && + (location.parent.kind === 240 /* ImportSpecifier */ || location.parent.kind === 244 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -66406,6 +67173,11 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -66473,7 +67245,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -66845,10 +67617,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -66899,7 +67671,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 /* ModuleDeclaration */ && + return declaration.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -66960,7 +67732,7 @@ var ts; ts.Debug.assert(classifications.spans.length % 3 === 0); var dense = classifications.spans; var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -67063,16 +67835,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 281 /* JSDocParameterTag */: + case 282 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 284 /* JSDocTemplateTag */: + case 285 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 283 /* JSDocTypeTag */: + case 284 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 282 /* JSDocReturnTag */: + case 283 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -67159,22 +67931,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -67202,10 +67974,10 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 223 /* VariableDeclaration */ || + if (token.parent.kind === 224 /* VariableDeclaration */ || token.parent.kind === 147 /* PropertyDeclaration */ || token.parent.kind === 144 /* Parameter */ || - token.parent.kind === 250 /* JsxAttribute */) { + token.parent.kind === 251 /* JsxAttribute */) { return 5 /* operator */; } } @@ -67222,7 +67994,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 250 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 251 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -67238,7 +68010,7 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -67248,17 +68020,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -67280,9 +68052,8 @@ var ts; // Ignore nodes that don't intersect the original span to classify. if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); @@ -67323,7 +68094,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 249 /* JsxClosingElement */) { + location.parent && location.parent.kind === 250 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -67350,14 +68121,14 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_44 in nameTable) { + for (var name_45 in nameTable) { // Skip identifiers produced only from the current location - if (nameTable[name_44] === position) { + if (nameTable[name_45] === position) { continue; } - if (!uniqueNames[name_44]) { - uniqueNames[name_44] = name_44; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, /*performCharacterChecks*/ true); + if (!uniqueNames[name_45]) { + uniqueNames[name_45] = name_45; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -67417,7 +68188,7 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression @@ -67443,7 +68214,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 235 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 236 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); @@ -67512,6 +68283,9 @@ var ts; return undefined; } function addStringLiteralCompletionsFromType(type, result) { + if (type && type.flags & 16384 /* TypeParameter */) { + type = typeChecker.getApparentType(type); + } if (!type) { return; } @@ -67870,11 +68644,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_13; + currentDir = parent_14; } else { break; @@ -68026,9 +68800,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283 /* JSDocTypeTag */: - case 281 /* JSDocParameterTag */: - case 282 /* JSDocReturnTag */: + case 284 /* JSDocTypeTag */: + case 282 /* JSDocParameterTag */: + case 283 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -68073,13 +68847,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_14.kind === 177 /* PropertyAccessExpression */) { + if (parent_15.kind === 177 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141 /* QualifiedName */) { + else if (parent_15.kind === 141 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -68094,7 +68868,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 249 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 250 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -68199,7 +68973,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247 /* JsxSelfClosingElement */) || (jsxContainer.kind === 248 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 248 /* JsxSelfClosingElement */) || (jsxContainer.kind === 249 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -68247,9 +69021,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 /* SourceFile */ || + scopeNode.kind === 262 /* SourceFile */ || scopeNode.kind === 194 /* TemplateExpression */ || - scopeNode.kind === 252 /* JsxExpression */ || + scopeNode.kind === 253 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -68282,11 +69056,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 248 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 249 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 249 /* JsxClosingElement */ || contextToken.parent.kind === 247 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246 /* JsxElement */; + if (contextToken.parent.kind === 250 /* JsxClosingElement */ || contextToken.parent.kind === 248 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 247 /* JsxElement */; } } return false; @@ -68316,16 +69090,16 @@ var ts; case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 230 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 231 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 226 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 227 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 223 /* VariableDeclaration */ // const x = a| + return containingNodeKind === 224 /* VariableDeclaration */ // const x = a| || containingNodeKind === 192 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 202 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 203 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: @@ -68439,9 +69213,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 /* NamedImports */ ? - 235 /* ImportDeclaration */ : - 241 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 239 /* NamedImports */ ? + 236 /* ImportDeclaration */ : + 242 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -68466,9 +69240,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 /* ObjectLiteralExpression */ || parent_15.kind === 172 /* ObjectBindingPattern */)) { - return parent_15; + var parent_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 /* ObjectLiteralExpression */ || parent_16.kind === 172 /* ObjectBindingPattern */)) { + return parent_16; } break; } @@ -68485,8 +69259,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return contextToken.parent; } } @@ -68495,37 +69269,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent_17 = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - if (parent_16 && (parent_16.kind === 247 /* JsxSelfClosingElement */ || parent_16.kind === 248 /* JsxOpeningElement */)) { - return parent_16; + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: + if (parent_17 && (parent_17.kind === 248 /* JsxSelfClosingElement */ || parent_17.kind === 249 /* JsxOpeningElement */)) { + return parent_17; } - else if (parent_16.kind === 250 /* JsxAttribute */) { - return parent_16.parent; + else if (parent_17.kind === 251 /* JsxAttribute */) { + return parent_17.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_16 && ((parent_16.kind === 250 /* JsxAttribute */) || (parent_16.kind === 251 /* JsxSpreadAttribute */))) { - return parent_16.parent; + if (parent_17 && ((parent_17.kind === 251 /* JsxAttribute */) || (parent_17.kind === 252 /* JsxSpreadAttribute */))) { + return parent_17.parent; } break; case 17 /* CloseBraceToken */: - if (parent_16 && - parent_16.kind === 252 /* JsxExpression */ && - parent_16.parent && - (parent_16.parent.kind === 250 /* JsxAttribute */)) { - return parent_16.parent.parent; + if (parent_17 && + parent_17.kind === 253 /* JsxExpression */ && + parent_17.parent && + (parent_17.parent.kind === 251 /* JsxAttribute */)) { + return parent_17.parent.parent; } - if (parent_16 && parent_16.kind === 251 /* JsxSpreadAttribute */) { - return parent_16.parent; + if (parent_17 && parent_17.kind === 252 /* JsxSpreadAttribute */) { + return parent_17.parent; } break; } @@ -68536,7 +69310,7 @@ var ts; switch (kind) { case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -68555,16 +69329,16 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 223 /* VariableDeclaration */ || - containingNodeKind === 224 /* VariableDeclarationList */ || - containingNodeKind === 205 /* VariableStatement */ || - containingNodeKind === 229 /* EnumDeclaration */ || + return containingNodeKind === 224 /* VariableDeclaration */ || + containingNodeKind === 225 /* VariableDeclarationList */ || + containingNodeKind === 206 /* VariableStatement */ || + containingNodeKind === 230 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 226 /* ClassDeclaration */ || + containingNodeKind === 227 /* ClassDeclaration */ || containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || containingNodeKind === 173 /* ArrayBindingPattern */ || - containingNodeKind === 228 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 229 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: @@ -68572,22 +69346,22 @@ var ts; case 20 /* OpenBracketToken */: return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 256 /* CatchClause */ || + return containingNodeKind === 257 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 229 /* EnumDeclaration */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || + return containingNodeKind === 230 /* EnumDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || containingNodeKind === 161 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: return containingNodeKind === 146 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 228 /* InterfaceDeclaration */ || contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 226 /* ClassDeclaration */ || + return containingNodeKind === 227 /* ClassDeclaration */ || containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 228 /* TypeAliasDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || + containingNodeKind === 229 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: return containingNodeKind === 147 /* PropertyDeclaration */; @@ -68600,9 +69374,9 @@ var ts; case 112 /* ProtectedKeyword */: return containingNodeKind === 144 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 239 /* ImportSpecifier */ || - containingNodeKind === 243 /* ExportSpecifier */ || - containingNodeKind === 237 /* NamespaceImport */; + return containingNodeKind === 240 /* ImportSpecifier */ || + containingNodeKind === 244 /* ExportSpecifier */ || + containingNodeKind === 238 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: @@ -68662,8 +69436,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_45 = element.propertyName || element.name; - existingImportsOrExports[name_45.text] = true; + var name_46 = element.propertyName || element.name; + existingImportsOrExports[name_46.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -68684,8 +69458,8 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 257 /* PropertyAssignment */ && - m.kind !== 258 /* ShorthandPropertyAssignment */ && + if (m.kind !== 258 /* PropertyAssignment */ && + m.kind !== 259 /* ShorthandPropertyAssignment */ && m.kind !== 174 /* BindingElement */ && m.kind !== 149 /* MethodDeclaration */ && m.kind !== 151 /* GetAccessor */ && @@ -68727,7 +69501,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250 /* JsxAttribute */) { + if (attr.kind === 251 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -68908,58 +69682,58 @@ var ts; switch (node.kind) { case 89 /* IfKeyword */: case 81 /* ElseKeyword */: - if (hasKind(node.parent, 208 /* IfStatement */)) { + if (hasKind(node.parent, 209 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 216 /* ReturnStatement */)) { + if (hasKind(node.parent, 217 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 220 /* ThrowStatement */)) { + if (hasKind(node.parent, 221 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 221 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 222 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101 /* TryKeyword */: case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 221 /* TryStatement */)) { + if (hasKind(parent(node), 222 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 218 /* SwitchStatement */)) { + if (hasKind(node.parent, 219 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72 /* CaseKeyword */: case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 218 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 219 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71 /* BreakKeyword */: case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 215 /* BreakStatement */) || hasKind(node.parent, 214 /* ContinueStatement */)) { + if (hasKind(node.parent, 216 /* BreakStatement */) || hasKind(node.parent, 215 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87 /* ForKeyword */: - if (hasKind(node.parent, 211 /* ForStatement */) || - hasKind(node.parent, 212 /* ForInStatement */) || - hasKind(node.parent, 213 /* ForOfStatement */)) { + if (hasKind(node.parent, 212 /* ForStatement */) || + hasKind(node.parent, 213 /* ForInStatement */) || + hasKind(node.parent, 214 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105 /* WhileKeyword */: case 80 /* DoKeyword */: - if (hasKind(node.parent, 210 /* WhileStatement */) || hasKind(node.parent, 209 /* DoStatement */)) { + if (hasKind(node.parent, 211 /* WhileStatement */) || hasKind(node.parent, 210 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -68976,7 +69750,7 @@ var ts; break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 206 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -68992,10 +69766,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 220 /* ThrowStatement */) { + if (node.kind === 221 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 221 /* TryStatement */) { + else if (node.kind === 222 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -69022,19 +69796,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261 /* SourceFile */) { - return parent_17; + var parent_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262 /* SourceFile */) { + return parent_18; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_17.kind === 221 /* TryStatement */) { - var tryStatement = parent_17; + if (parent_18.kind === 222 /* TryStatement */) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_17; + child = parent_18; } return undefined; } @@ -69043,7 +69817,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 /* BreakStatement */ || node.kind === 214 /* ContinueStatement */) { + if (node.kind === 216 /* BreakStatement */ || node.kind === 215 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -69056,25 +69830,25 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 218 /* SwitchStatement */: - if (statement.kind === 214 /* ContinueStatement */) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 219 /* SwitchStatement */: + if (statement.kind === 215 /* ContinueStatement */) { continue; } // Fall through. - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: // Don't cross function boundaries. - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -69086,24 +69860,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 226 /* ClassDeclaration */ || + if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */ || (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { return undefined; } } else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { + if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { return undefined; } } else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 231 /* ModuleBlock */ || container.kind === 261 /* SourceFile */)) { + if (!(container.kind === 232 /* ModuleBlock */ || container.kind === 262 /* SourceFile */)) { return undefined; } } else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || declaration.kind === 226 /* ClassDeclaration */)) { + if (!(container.kind === 227 /* ClassDeclaration */ || declaration.kind === 227 /* ClassDeclaration */)) { return undefined; } } @@ -69115,8 +69889,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: + case 232 /* ModuleBlock */: + case 262 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -69128,7 +69902,7 @@ var ts; case 150 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search @@ -69212,7 +69986,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 209 /* DoStatement */) { + if (loopNode.kind === 210 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { @@ -69233,13 +70007,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -69293,7 +70067,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 204 /* Block */))) { + if (!(func && hasKind(func.body, 205 /* Block */))) { return undefined; } var keywords = []; @@ -69309,7 +70083,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 208 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 209 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -69322,7 +70096,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 208 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 209 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -69365,7 +70139,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 220 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -69599,12 +70373,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 236 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 237 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 /* ImportSpecifier */ || - declaration.kind === 243 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 /* ImportSpecifier */ || + declaration.kind === 244 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -69612,7 +70386,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 239 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 240 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -69671,7 +70445,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 227 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -69702,7 +70476,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 262 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -69978,7 +70752,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 259 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -69991,24 +70765,24 @@ var ts; // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); + var parent_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204 /* Block */) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 205 /* Block */) { + ts.forEachReturnStatement(parent_19.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); + else if (isImplementationExpression(parent_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -70049,7 +70823,7 @@ var ts; function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { if (node.kind === 199 /* ExpressionWithTypeArguments */ - && node.parent.kind === 255 /* HeritageClause */ + && node.parent.kind === 256 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -70120,7 +70894,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { + else if (declaration.kind === 228 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -70200,12 +70974,12 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, @@ -70215,7 +70989,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 261 /* SourceFile */) { + if (searchSpaceNode.kind === 262 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -70250,7 +71024,7 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } @@ -70262,15 +71036,15 @@ var ts; } break; case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 261 /* SourceFile */: - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { + case 262 /* SourceFile */: + if (container.kind === 262 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -70306,13 +71080,13 @@ var ts; for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { var position = possiblePositions_1[_i]; cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { + var node_3 = ts.getTouchingWord(sourceFile, position); + if (!node_3 || node_3.kind !== 9 /* StringLiteral */) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + references.push(getReferenceEntryFromNode(node_3)); } } } @@ -70324,7 +71098,7 @@ var ts; // Search the property symbol // for ( { property: p2 } of elems) { } var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258 /* ShorthandPropertyAssignment */) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259 /* ShorthandPropertyAssignment */) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -70427,7 +71201,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { + else if (declaration.kind === 228 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -70593,7 +71367,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223 /* VariableDeclaration */) { + else if (node.kind === 224 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -70603,18 +71377,18 @@ var ts; } else { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 224 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 206 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 225 /* VariableDeclarationList */); return node.parent.parent; } } @@ -70689,8 +71463,8 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: @@ -70768,7 +71542,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 239 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 238 /* NamedImports */))) { + (declaration.kind === 240 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 239 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -70777,7 +71551,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -70861,7 +71635,7 @@ var ts; var definition; ts.forEach(signatureDeclarations, function (d) { if ((selectConstructors && d.kind === 150 /* Constructor */) || - (!selectConstructors && (d.kind === 225 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { + (!selectConstructors && (d.kind === 226 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -70941,7 +71715,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // 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 === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -71048,7 +71822,7 @@ var ts; */ function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -71108,19 +71882,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 150 /* Constructor */: - case 226 /* ClassDeclaration */: - case 205 /* VariableStatement */: + case 227 /* ClassDeclaration */: + case 206 /* VariableStatement */: break findOwner; - case 261 /* SourceFile */: + case 262 /* SourceFile */: return undefined; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 230 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 231 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -71135,7 +71909,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : @@ -71167,7 +71941,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205 /* VariableStatement */) { + if (commentOwner.kind === 206 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -71287,9 +72061,9 @@ var ts; } } // Add the cached typing locations for inferred typings that are already installed - for (var name_46 in packageNameToTypingLocation) { - if (name_46 in inferredTypings && !inferredTypings[name_46]) { - inferredTypings[name_46] = packageNameToTypingLocation[name_46]; + for (var name_47 in packageNameToTypingLocation) { + if (name_47 in inferredTypings && !inferredTypings[name_47]) { + inferredTypings[name_47] = packageNameToTypingLocation[name_47]; } } // Remove typings that the user has added to the exclude list @@ -71427,12 +72201,12 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + for (var name_48 in nameToDeclarations) { + var declarations = nameToDeclarations[name_48]; if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); if (!matches) { continue; } @@ -71445,14 +72219,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name_48); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -71460,7 +72234,7 @@ var ts; // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 /* ImportClause */ || decl.kind === 239 /* ImportSpecifier */ || decl.kind === 234 /* ImportEqualsDeclaration */) { + if (decl.kind === 237 /* ImportClause */ || decl.kind === 240 /* ImportSpecifier */ || decl.kind === 235 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -71715,7 +72489,7 @@ var ts; addLeafNode(node); } break; - case 236 /* ImportClause */: + case 237 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -71727,7 +72501,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 238 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -71739,11 +72513,11 @@ var ts; } break; case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name_49 = decl.name; + if (ts.isBindingPattern(name_49)) { + addChildrenRecursively(name_49); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -71754,11 +72528,11 @@ var ts; } break; case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -71768,9 +72542,9 @@ var ts; } endNode(); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -71778,21 +72552,21 @@ var ts; } endNode(); break; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243 /* ExportSpecifier */: - case 234 /* ImportEqualsDeclaration */: + case 244 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: case 155 /* IndexSignature */: case 153 /* CallSignature */: case 154 /* ConstructSignature */: - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285 /* JSDocTypedefTag */) { + if (tag.kind === 286 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -71843,14 +72617,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 231 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230 /* ModuleDeclaration */) { + if (a.body.kind !== 231 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -71910,7 +72684,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 231 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -71922,14 +72696,14 @@ var ts; case 185 /* ArrowFunction */: case 197 /* ClassExpression */: return getFunctionOrClassName(node); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 231 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -71940,15 +72714,15 @@ var ts; } } switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; @@ -71965,7 +72739,7 @@ var ts; return "()"; case 155 /* IndexSignature */: return "[]"; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -71977,7 +72751,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 206 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -72006,23 +72780,23 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: - case 228 /* TypeAliasDeclaration */: - case 285 /* JSDocTypedefTag */: + case 230 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 262 /* SourceFile */: + case 229 /* TypeAliasDeclaration */: + case 286 /* JSDocTypedefTag */: return true; case 150 /* Constructor */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return hasSomeImportantChild(item); case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: @@ -72033,8 +72807,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: + case 232 /* ModuleBlock */: + case 262 /* SourceFile */: case 149 /* MethodDeclaration */: case 150 /* Constructor */: return true; @@ -72045,7 +72819,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; + return childKind !== 224 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; }); } } @@ -72103,7 +72877,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -72114,13 +72888,13 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 230 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 231 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { return !member.name || member.name.kind === 142 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 261 /* SourceFile */ + return node.kind === 262 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -72128,14 +72902,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223 /* VariableDeclaration */) { + else if (node.parent.kind === 224 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } else if (node.parent.kind === 192 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -72248,30 +73022,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204 /* Block */: + case 205 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent_20 = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_19.kind === 209 /* DoStatement */ || - parent_19.kind === 212 /* ForInStatement */ || - parent_19.kind === 213 /* ForOfStatement */ || - parent_19.kind === 211 /* ForStatement */ || - parent_19.kind === 208 /* IfStatement */ || - parent_19.kind === 210 /* WhileStatement */ || - parent_19.kind === 217 /* WithStatement */ || - parent_19.kind === 256 /* CatchClause */) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent_20.kind === 210 /* DoStatement */ || + parent_20.kind === 213 /* ForInStatement */ || + parent_20.kind === 214 /* ForOfStatement */ || + parent_20.kind === 212 /* ForStatement */ || + parent_20.kind === 209 /* IfStatement */ || + parent_20.kind === 211 /* WhileStatement */ || + parent_20.kind === 218 /* WithStatement */ || + parent_20.kind === 257 /* CatchClause */) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221 /* TryStatement */) { + if (parent_20.kind === 222 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_19; + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -72294,17 +73068,17 @@ var ts; break; } // Fallthrough. - case 231 /* ModuleBlock */: { + case 232 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: - case 232 /* CaseBlock */: { + case 233 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); @@ -72690,7 +73464,8 @@ var ts; } // Assumes 'value' is already lowercase. function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -72699,7 +73474,7 @@ var ts; } // Assumes 'value' is already lowercase. function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -72771,7 +73546,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -73597,7 +74372,7 @@ var ts; var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 203 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; @@ -73728,7 +74503,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 262 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -74124,7 +74899,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 231 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -74161,7 +74936,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 228 /* TypeAliasDeclaration */) { + else if (declaration.kind === 229 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -74177,7 +74952,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260 /* EnumMember */) { + if (declaration.kind === 261 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -74189,7 +74964,7 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 234 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); @@ -74200,7 +74975,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234 /* ImportEqualsDeclaration */) { + if (declaration.kind === 235 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -74273,7 +75048,7 @@ var ts; // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 192 /* BinaryExpression */) { @@ -74360,13 +75135,13 @@ var ts; if (declaration.kind === 184 /* FunctionExpression */) { return true; } - if (declaration.kind !== 223 /* VariableDeclaration */ && declaration.kind !== 225 /* FunctionDeclaration */) { + if (declaration.kind !== 224 /* VariableDeclaration */ && declaration.kind !== 226 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { + for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { // Reached source file or module block - if (parent_20.kind === 261 /* SourceFile */ || parent_20.kind === 231 /* ModuleBlock */) { + if (parent_21.kind === 262 /* SourceFile */ || parent_21.kind === 232 /* ModuleBlock */) { return false; } } @@ -74604,10 +75379,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 250 /* JsxAttribute */: - case 248 /* JsxOpeningElement */: - case 249 /* JsxClosingElement */: - case 247 /* JsxSelfClosingElement */: + case 251 /* JsxAttribute */: + case 249 /* JsxOpeningElement */: + case 250 /* JsxClosingElement */: + case 248 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -75019,11 +75794,11 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 140 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75040,10 +75815,10 @@ var ts; this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); @@ -75073,6 +75848,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109 /* LetKeyword */, 75 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75089,11 +75865,12 @@ var ts; this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -75130,6 +75907,8 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + // No space before non-null assertion operator + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -75160,7 +75939,7 @@ var ts; this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, // TypeScript-specific rules - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -75175,6 +75954,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; // These rules are lower in priority than user-configurable rules. this.LowPriorityCommonRules = [ @@ -75184,7 +75964,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; /// @@ -75242,9 +76021,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name_50 in o) { + if (o[name_50] === rule) { + return name_50; } } throw new Error("Unknown rule"); @@ -75253,7 +76032,7 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 211 /* ForStatement */; + return context.contextNode.kind === 212 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); @@ -75263,8 +76042,8 @@ var ts; case 192 /* BinaryExpression */: case 193 /* ConditionalExpression */: case 200 /* AsExpression */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: case 156 /* TypePredicate */: case 164 /* UnionType */: case 165 /* IntersectionType */: @@ -75272,22 +76051,24 @@ var ts; // equals in binding elements: function foo([[x, y] = [1, 2]]) case 174 /* BindingElement */: // equals in type X = ... - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: // equal in p = 0; case 144 /* Parameter */: - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: + // "in" keyword in [P in keyof T]: T[P] + case 143 /* TypeParameter */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; } return false; @@ -75317,6 +76098,9 @@ var ts; //// * ) and { are on different lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 172 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); + }; // This check is done before an open brace in a control construct, a function, or a typescript block declaration Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -75340,17 +76124,17 @@ var ts; return true; } switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: + case 205 /* Block */: + case 233 /* CaseBlock */: case 176 /* ObjectLiteralExpression */: - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -75364,60 +76148,66 @@ var ts; // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; + return context.contextNode.kind === 226 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 161 /* TypeLiteral */: - case 230 /* ModuleDeclaration */: - case 241 /* ExportDeclaration */: - case 242 /* NamedExports */: - case 235 /* ImportDeclaration */: - case 238 /* NamedImports */: + case 231 /* ModuleDeclaration */: + case 242 /* ExportDeclaration */: + case 243 /* NamedExports */: + case 236 /* ImportDeclaration */: + case 239 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226 /* ClassDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 204 /* Block */: - case 256 /* CatchClause */: - case 231 /* ModuleBlock */: - case 218 /* SwitchStatement */: + case 227 /* ClassDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 257 /* CatchClause */: + case 232 /* ModuleBlock */: + case 219 /* SwitchStatement */: return true; + case 205 /* Block */: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 185 /* ArrowFunction */ && + blockParent.kind !== 184 /* FunctionExpression */) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208 /* IfStatement */: - case 218 /* SwitchStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 221 /* TryStatement */: - case 209 /* DoStatement */: - case 217 /* WithStatement */: + case 209 /* IfStatement */: + case 219 /* SwitchStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 222 /* TryStatement */: + case 210 /* DoStatement */: + case 218 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 256 /* CatchClause */: + case 257 /* CatchClause */: return true; default: return false; @@ -75448,19 +76238,19 @@ var ts; return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246 /* JsxElement */; + return context.contextNode.kind !== 247 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252 /* JsxExpression */; + return context.contextNode.kind === 253 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250 /* JsxAttribute */; + return context.nextTokenParent.kind === 251 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250 /* JsxAttribute */; + return context.contextNode.kind === 251 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247 /* JsxSelfClosingElement */; + return context.contextNode.kind === 248 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -75478,14 +76268,14 @@ var ts; return node.kind === 145 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 225 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230 /* ModuleDeclaration */; + return context.contextNode.kind === 231 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -75497,10 +76287,11 @@ var ts; switch (parent.kind) { case 157 /* TypeReference */: case 182 /* TypeAssertionExpression */: - case 226 /* ClassDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: @@ -75528,6 +76319,9 @@ var ts; Rules.IsYieldOrYieldStarWithOperand = function (context) { return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 201 /* NonNullExpression */; + }; return Rules; }()); formatting.Rules = Rules; @@ -75846,6 +76640,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -75926,6 +76726,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -76058,17 +76864,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 231 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 261 /* SourceFile */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + return body && body.kind === 232 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 262 /* SourceFile */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -76273,10 +77079,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 227 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 225 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 229 /* EnumDeclaration */: return 229 /* EnumDeclaration */; + case 227 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 228 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 226 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 230 /* EnumDeclaration */: return 230 /* EnumDeclaration */; case 151 /* GetAccessor */: return 124 /* GetKeyword */; case 152 /* SetAccessor */: return 133 /* SetKeyword */; case 149 /* MethodDeclaration */: @@ -76316,18 +77122,31 @@ var ts; // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent case 16 /* OpenBraceToken */: case 17 /* CloseBraceToken */: - case 20 /* OpenBracketToken */: - case 21 /* CloseBracketToken */: case 18 /* OpenParenToken */: case 19 /* CloseParenToken */: case 81 /* ElseKeyword */: case 105 /* WhileKeyword */: case 56 /* AtToken */: return indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40 /* SlashToken */: + case 28 /* GreaterThanToken */: { + if (container.kind === 249 /* JsxOpeningElement */ || + container.kind === 250 /* JsxClosingElement */ || + container.kind === 248 /* JsxSelfClosingElement */) { + return indentation; + } + break; + } + case 20 /* OpenBracketToken */: + case 21 /* CloseBracketToken */: { + if (container.kind !== 170 /* MappedType */) { + return indentation; + } + break; + } } + // if token line equals to the line of containing node (this is a first token in the node) - use node indentation + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -76383,7 +77202,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -76417,7 +77236,7 @@ var ts; // stop when formatting scanner advances past the beginning of the child break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -76457,11 +77276,11 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -76479,7 +77298,7 @@ var ts; // without this check close paren will be interpreted as list end token for function expression which is wrong if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -76686,7 +77505,7 @@ var ts; } // shift all parts on the delta size var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -76792,7 +77611,7 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -77052,7 +77871,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 261 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 262 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -77085,7 +77904,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 209 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -77107,7 +77926,7 @@ var ts; return node.parent.properties; case 175 /* ArrayLiteralExpression */: return node.parent.elements; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: @@ -77241,35 +78060,36 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207 /* ExpressionStatement */: - case 226 /* ClassDeclaration */: + case 208 /* ExpressionStatement */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 229 /* TypeAliasDeclaration */: case 175 /* ArrayLiteralExpression */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: case 176 /* ObjectLiteralExpression */: case 161 /* TypeLiteral */: + case 170 /* MappedType */: case 163 /* TupleType */: - case 232 /* CaseBlock */: - case 254 /* DefaultClause */: - case 253 /* CaseClause */: + case 233 /* CaseBlock */: + case 255 /* DefaultClause */: + case 254 /* CaseClause */: case 183 /* ParenthesizedExpression */: case 177 /* PropertyAccessExpression */: case 179 /* CallExpression */: case 180 /* NewExpression */: - case 205 /* VariableStatement */: - case 223 /* VariableDeclaration */: - case 240 /* ExportAssignment */: - case 216 /* ReturnStatement */: + case 206 /* VariableStatement */: + case 224 /* VariableDeclaration */: + case 241 /* ExportAssignment */: + case 217 /* ReturnStatement */: case 193 /* ConditionalExpression */: case 173 /* ArrayBindingPattern */: case 172 /* ObjectBindingPattern */: - case 248 /* JsxOpeningElement */: - case 247 /* JsxSelfClosingElement */: - case 252 /* JsxExpression */: + case 249 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 253 /* JsxExpression */: case 148 /* MethodSignature */: case 153 /* CallSignature */: case 154 /* ConstructSignature */: @@ -77279,10 +78099,10 @@ var ts; case 166 /* ParenthesizedType */: case 181 /* TaggedTemplateExpression */: case 189 /* AwaitExpression */: - case 242 /* NamedExports */: - case 238 /* NamedImports */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 243 /* NamedExports */: + case 239 /* NamedImports */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: return true; } return false; @@ -77291,27 +78111,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 208 /* IfStatement */: - case 225 /* FunctionDeclaration */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 212 /* ForStatement */: + case 209 /* IfStatement */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 185 /* ArrowFunction */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - return childKind !== 204 /* Block */; - case 241 /* ExportDeclaration */: - return childKind !== 242 /* NamedExports */; - case 235 /* ImportDeclaration */: - return childKind !== 236 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 238 /* NamedImports */); - case 246 /* JsxElement */: - return childKind !== 249 /* JsxClosingElement */; + return childKind !== 205 /* Block */; + case 242 /* ExportDeclaration */: + return childKind !== 243 /* NamedExports */; + case 236 /* ImportDeclaration */: + return childKind !== 237 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 239 /* NamedImports */); + case 247 /* JsxElement */: + return childKind !== 250 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -77367,25 +78187,128 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122 /* ConstructorKeyword */) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1 /* Number */); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0 /* String */); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1 /* Number */, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0 /* String */, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_7 = writer.string(); + ts.releaseStringWriter(writer); + return result_7; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + // This is the identifier in the case of a class declaration + // or the class keyword token in the case of a class expression. + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -77409,7 +78332,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -77425,7 +78348,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -77439,6 +78362,227 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122 /* ConstructorKeyword */) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 /* Identifier */ && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84 /* ExtendsKeyword */)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + // We replace existing keywords with commas. + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + // this handles var ["computed"] = 12; + if (token.kind === 20 /* OpenBracketToken */) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70 /* Identifier */: + switch (token.parent.kind) { + case 224 /* VariableDeclaration */: + switch (token.parent.parent.parent.kind) { + case 212 /* ForStatement */: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 214 /* ForOfStatement */: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 213 /* ForInStatement */: + // There is no valid fix in the case of: + // for .. in + return undefined; + case 257 /* CatchClause */: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143 /* TypeParameter */: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144 /* Parameter */: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + // handle case where 'import a = A;' + case 235 /* ImportEqualsDeclaration */: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 240 /* ImportSpecifier */: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + // Only 1 import and it is unused. So the entire declaration should be removed. + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + // handle case where "import d, * as ns from './file'" + // or "'import {a, b as ns} from './file'" + case 237 /* ImportClause */: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 238 /* NamespaceImport */: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147 /* PropertyDeclaration */: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 238 /* NamespaceImport */: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 236 /* ImportDeclaration */ && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + 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); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -77538,7 +78682,10 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -77550,6 +78697,11 @@ var ts; // this is a module id -> module import declaration map var cachedImportDeclarations = ts.createMap(); var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -77557,7 +78709,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -77597,10 +78748,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { return node; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -77618,7 +78769,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { // With an existing import statement, there are more than one actions the user can do. @@ -77646,9 +78797,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { var declaration = declarations_11[_i]; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 236 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 238 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -77672,7 +78823,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { /** * If the existing import declaration already has a named import list, just @@ -77688,7 +78839,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 246 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -77736,7 +78887,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 236 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -77773,7 +78924,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; // 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. @@ -77793,7 +78946,7 @@ var ts; tryGetModuleNameAsNodeModule() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 262 /* SourceFile */) { return moduleSymbol.name; } } @@ -77806,6 +78959,7 @@ var ts; if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -77825,7 +78979,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -77947,156 +79101,149 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - // this handles var ["computed"] = 12; - if (token.kind === 20 /* OpenBracketToken */) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70 /* Identifier */: - switch (token.parent.kind) { - case 223 /* VariableDeclaration */: - switch (token.parent.parent.parent.kind) { - case 211 /* ForStatement */: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213 /* ForOfStatement */: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212 /* ForInStatement */: - // There is no valid fix in the case of: - // for .. in - return undefined; - case 256 /* CatchClause */: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143 /* TypeParameter */: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144 /* Parameter */: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - // handle case where 'import a = A;' - case 234 /* ImportEqualsDeclaration */: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239 /* ImportSpecifier */: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - // Only 1 import and it is unused. So the entire declaration should be removed. - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - // handle case where "import d, * as ns from './file'" - // or "'import {a, b as ns} from './file'" - case 236 /* ImportClause */: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237 /* NamespaceImport */: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147 /* PropertyDeclaration */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237 /* NamespaceImport */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 /* ImportDeclaration */ && importDecl.parent) { - importDecl = importDecl.parent; + /** + * Finds members of the resolved type that are missing in the class pointed to by class decl + * and generates source code for the missing members. + * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. + * @returns Empty string iff there are no member insertions. + */ + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + /** + * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. + */ + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + // const name = symbol.getName(); + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 146 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 148 /* MethodSignature */: + case 149 /* MethodDeclaration */: + // The signature for the implementation appears as an entry in `signatures` iff + // there is only one signature. + // If there are overloads and an implementation signature, it appears as an + // extra declaration that isn't a signature for `type`. + // 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. + var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + // If there is a declaration with a body, it is the last declaration, + // and it isn't caught by `getSignaturesOfType`. + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(153 /* CallSignature */); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54 /* QuestionToken */); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23 /* DotDotDotToken */); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(144 /* Parameter */); + newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4 /* Public */) { + return "public "; + } + else if (flags & 16 /* Protected */) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// /// /// /// @@ -78122,7 +79269,7 @@ var ts; /// /// /// -/// +/// /// var ts; (function (ts) { @@ -78187,7 +79334,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(293 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -78210,7 +79357,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 /* FirstJSDocTagNode */ && this.kind <= 291 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 279 /* FirstJSDocTagNode */ && this.kind <= 292 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -78489,9 +79636,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_7 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_7 !== undefined) { - return result_7; + var result_8 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_8 !== undefined) { + return result_8; } if (declaration.name.kind === 142 /* ComputedPropertyName */) { var expr = declaration.name.expression; @@ -78515,7 +79662,7 @@ var ts; } function visit(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -78538,18 +79685,18 @@ var ts; } ts.forEachChild(node, visit); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 161 /* TypeLiteral */: @@ -78562,7 +79709,7 @@ var ts; break; } // fall through - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { @@ -78572,19 +79719,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: addDeclaration(node); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -78596,7 +79743,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -79297,7 +80444,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 230 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 231 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -79529,7 +80676,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -79683,7 +80830,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 245 /* ExternalModuleReference */ || + node.parent.kind === 246 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -79787,16 +80934,16 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return spanInVariableDeclaration(node); case 144 /* Parameter */: return spanInParameterDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -79805,85 +80952,85 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 204 /* Block */: + case 205 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return spanInBlock(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return spanInBlock(node.block); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* DoStatement */: + case 210 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 208 /* IfStatement */: + case 209 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return spanInForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 221 /* TryStatement */: + case 222 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: case 174 /* BindingElement */: // span on complete node return textSpan(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: // span in statement return spanInNode(node.statement); case 145 /* Decorator */: @@ -79892,8 +81039,8 @@ var ts; case 173 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -79937,8 +81084,8 @@ var ts; // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 70 /* Identifier */ || node.kind == 196 /* SpreadElement */ || - node.kind === 257 /* PropertyAssignment */ || - node.kind === 258 /* ShorthandPropertyAssignment */) && + node.kind === 258 /* PropertyAssignment */ || + node.kind === 259 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } @@ -79965,14 +81112,14 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209 /* DoStatement */: + case 210 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 145 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: return textSpan(node); case 192 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { @@ -79989,7 +81136,7 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); @@ -80003,7 +81150,7 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 223 /* VariableDeclaration */ || + if ((node.parent.kind === 224 /* VariableDeclaration */ || node.parent.kind === 144 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || @@ -80038,7 +81185,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 212 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 213 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -80049,7 +81196,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 213 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 214 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -80089,7 +81236,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 226 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); + (functionDeclaration.parent.kind === 227 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -80112,25 +81259,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 210 /* WhileStatement */: - case 208 /* IfStatement */: - case 212 /* ForInStatement */: + case 211 /* WhileStatement */: + case 209 /* IfStatement */: + case 213 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 225 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -80184,13 +81331,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -80198,24 +81345,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 229 /* EnumDeclaration */: - case 226 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 204 /* Block */: + case 205 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 256 /* CatchClause */: + case 257 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -80254,7 +81401,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 /* DoStatement */ || + if (node.parent.kind === 210 /* DoStatement */ || node.parent.kind === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { return spanInPreviousNode(node); @@ -80269,17 +81416,17 @@ var ts; // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 150 /* Constructor */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: case 179 /* CallExpression */: case 180 /* NewExpression */: case 183 /* ParenthesizedExpression */: @@ -80292,7 +81439,7 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 /* PropertyAssignment */ || + node.parent.kind === 258 /* PropertyAssignment */ || node.parent.kind === 144 /* Parameter */) { return spanInPreviousNode(node); } @@ -80305,7 +81452,7 @@ var ts; return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209 /* DoStatement */) { + if (node.parent.kind === 210 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -80313,7 +81460,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.kind === 214 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -81102,7 +82249,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index e11c200ef44..24ec0a740ca 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -239,102 +239,102 @@ declare namespace ts { ExpressionWithTypeArguments = 199, AsExpression = 200, NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, + MetaProperty = 202, + TemplateSpan = 203, + SemicolonClassElement = 204, + Block = 205, + VariableStatement = 206, + EmptyStatement = 207, + ExpressionStatement = 208, + IfStatement = 209, + DoStatement = 210, + WhileStatement = 211, + ForStatement = 212, + ForInStatement = 213, + ForOfStatement = 214, + ContinueStatement = 215, + BreakStatement = 216, + ReturnStatement = 217, + WithStatement = 218, + SwitchStatement = 219, + LabeledStatement = 220, + ThrowStatement = 221, + TryStatement = 222, + DebuggerStatement = 223, + VariableDeclaration = 224, + VariableDeclarationList = 225, + FunctionDeclaration = 226, + ClassDeclaration = 227, + InterfaceDeclaration = 228, + TypeAliasDeclaration = 229, + EnumDeclaration = 230, + ModuleDeclaration = 231, + ModuleBlock = 232, + CaseBlock = 233, + NamespaceExportDeclaration = 234, + ImportEqualsDeclaration = 235, + ImportDeclaration = 236, + ImportClause = 237, + NamespaceImport = 238, + NamedImports = 239, + ImportSpecifier = 240, + ExportAssignment = 241, + ExportDeclaration = 242, + NamedExports = 243, + ExportSpecifier = 244, + MissingDeclaration = 245, + ExternalModuleReference = 246, + JsxElement = 247, + JsxSelfClosingElement = 248, + JsxOpeningElement = 249, + JsxClosingElement = 250, + JsxAttribute = 251, + JsxSpreadAttribute = 252, + JsxExpression = 253, + CaseClause = 254, + DefaultClause = 255, + HeritageClause = 256, + CatchClause = 257, + PropertyAssignment = 258, + ShorthandPropertyAssignment = 259, + SpreadAssignment = 260, + EnumMember = 261, + SourceFile = 262, + JSDocTypeExpression = 263, + JSDocAllType = 264, + JSDocUnknownType = 265, + JSDocArrayType = 266, + JSDocUnionType = 267, + JSDocTupleType = 268, + JSDocNullableType = 269, + JSDocNonNullableType = 270, + JSDocRecordType = 271, + JSDocRecordMember = 272, + JSDocTypeReference = 273, + JSDocOptionalType = 274, + JSDocFunctionType = 275, + JSDocVariadicType = 276, + JSDocConstructorType = 277, + JSDocThisType = 278, + JSDocComment = 279, + JSDocTag = 280, + JSDocAugmentsTag = 281, + JSDocParameterTag = 282, + JSDocReturnTag = 283, + JSDocTypeTag = 284, + JSDocTemplateTag = 285, + JSDocTypedefTag = 286, + JSDocPropertyTag = 287, + JSDocTypeLiteral = 288, + JSDocLiteralType = 289, + JSDocNullKeyword = 290, + JSDocUndefinedKeyword = 291, + JSDocNeverKeyword = 292, + SyntaxList = 293, + NotEmittedStatement = 294, + PartiallyEmittedExpression = 295, + MergeDeclarationMarker = 296, + EndOfDeclarationMarker = 297, Count = 298, FirstAssignment = 57, LastAssignment = 69, @@ -361,10 +361,10 @@ declare namespace ts { FirstBinaryOperator = 26, LastBinaryOperator = 69, FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstJSDocNode = 263, + LastJSDocNode = 289, + FirstJSDocTagNode = 279, + LastJSDocTagNode = 292, } enum NodeFlags { None = 0, @@ -969,6 +969,11 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; @@ -1003,6 +1008,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1022,7 +1028,7 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; @@ -1569,6 +1575,7 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): ObjectType[]; @@ -1581,6 +1588,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -1603,11 +1612,13 @@ declare namespace ts { isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; + getApparentType(type: Type): Type; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1645,6 +1656,7 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, } enum SymbolFormatFlags { None = 0, @@ -1815,6 +1827,7 @@ declare namespace ts { interface ObjectType extends Type { objectFlags: ObjectFlags; } + /** Class and interface types (TypeFlags.Class and TypeFlags.Interface). */ interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; @@ -1828,6 +1841,16 @@ declare namespace ts { declaredStringIndexInfo: IndexInfo; declaredNumberIndexInfo: IndexInfo; } + /** + * Type references (TypeFlags.Reference). When a class or interface has type parameters or + * a "this" type, references to the class or interface are made using type references. The + * typeArguments property specifies the types to substitute for the type parameters of the + * class or interface and optionally includes an extra element that specifies the type to + * substitute for "this" in the resulting instantiation. When no extra argument is present, + * the type reference itself is substituted for "this". The typeArguments property is undefined + * if the class or interface has no type parameters and the reference isn't specifying an + * explicit "this" argument. + */ interface TypeReference extends ObjectType { target: GenericType; typeArguments: Type[]; @@ -2106,7 +2129,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -2325,9 +2347,28 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + /** + * Cached module resolutions per containing directory. + * This assumes that any module id will have the same resolution for sibling files located in the same folder. + */ + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; + } + /** + * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory + * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. + */ + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + } + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; + } + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; @@ -2674,6 +2715,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -2682,6 +2724,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -2689,6 +2732,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -2697,6 +2741,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 7f41e5d07f5..bae2811e4de 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword @@ -244,115 +249,115 @@ var ts; SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 202] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 202] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 203] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 203] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 204] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 204] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 205] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 206] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 207] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 208] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 209] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 210] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 211] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 212] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 213] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 214] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 215] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 216] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 217] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 218] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 219] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 220] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 221] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 222] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 224] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 225] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 226] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 227] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 228] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 229] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 230] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 231] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 232] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 233] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 234] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 235] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 236] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 237] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 238] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 239] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 240] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 241] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 242] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 243] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 244] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 205] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 206] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 207] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 208] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 209] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 210] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 211] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 212] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 213] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 214] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 215] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 216] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 217] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 218] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 219] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 220] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 221] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 222] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 223] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 225] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 226] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 227] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 228] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 229] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 230] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 231] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 232] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 233] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 234] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 235] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 236] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 237] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 238] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 239] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 240] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 241] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 242] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 243] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 244] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 245] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 246] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 246] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 247] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 248] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 249] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 250] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 251] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 252] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 247] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 248] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 249] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 250] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 251] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 252] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 253] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 253] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 254] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 255] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 256] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 254] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 255] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 256] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 257] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 257] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 258] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 259] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 258] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 259] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 260] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 260] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 261] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 261] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 262] = "SourceFile"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 262] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 263] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 263] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 264] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 264] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 265] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 266] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 267] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 268] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 269] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 270] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 271] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 272] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 273] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 274] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 275] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 276] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 277] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 278] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 279] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 280] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 281] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 282] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 283] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 284] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 285] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 286] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 288] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 289] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 290] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 291] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 265] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 266] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 267] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 268] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 269] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 270] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 271] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 272] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 273] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 274] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 275] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 276] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 277] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 278] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 279] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 280] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 281] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 282] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 283] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 284] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 285] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 286] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 287] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 288] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 289] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 290] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 291] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 292] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 292] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 293] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 293] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 294] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 295] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 296] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["RawExpression"] = 297] = "RawExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 294] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 295] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 296] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 297] = "EndOfDeclarationMarker"; // Enum value count SyntaxKind[SyntaxKind["Count"] = 298] = "Count"; // Markers @@ -381,10 +386,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 262] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 288] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 278] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 291] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 263] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 289] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 279] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 292] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -511,6 +516,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -647,6 +653,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; @@ -1290,7 +1297,7 @@ var ts; */ function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1314,7 +1321,7 @@ var ts; */ function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -1325,7 +1332,7 @@ var ts; ts.every = every; /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -1339,7 +1346,7 @@ var ts; * This is like `forEach`, but never returns undefined. */ function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1362,7 +1369,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -1372,7 +1379,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -2220,6 +2227,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -3915,7 +3923,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -4072,6 +4080,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -4301,6 +4310,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -4310,6 +4321,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -4361,6 +4373,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -4529,6 +4543,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -4542,10 +4557,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -4594,6 +4609,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -4650,22 +4667,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); /// @@ -5132,7 +5152,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -5344,7 +5364,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -6524,7 +6544,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261 /* SourceFile */) { + while (node && node.kind !== 262 /* SourceFile */) { node = node.parent; } return node; @@ -6532,11 +6552,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 205 /* Block */: + case 233 /* CaseBlock */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return true; } return false; @@ -6627,18 +6647,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 292 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 293 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 /* FirstJSDocNode */ && node.kind <= 288 /* LastJSDocNode */; + return node.kind >= 263 /* FirstJSDocNode */ && node.kind <= 289 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 /* FirstJSDocTagNode */ && node.kind <= 291 /* LastJSDocTagNode */; + return node.kind >= 279 /* FirstJSDocTagNode */ && node.kind <= 292 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6742,11 +6762,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 /* VariableDeclaration */ && node.parent.kind === 256 /* CatchClause */; + return node.kind === 224 /* VariableDeclaration */ && node.parent.kind === 257 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 /* ModuleDeclaration */ && + return node && node.kind === 231 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6757,11 +6777,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 230 /* ModuleDeclaration */ && (!node.body); + return node.kind === 231 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 /* SourceFile */ || - node.kind === 230 /* ModuleDeclaration */ || + return node.kind === 262 /* SourceFile */ || + node.kind === 231 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6777,9 +6797,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.isExternalModule(node.parent); - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6791,22 +6811,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 256 /* CatchClause */: - case 230 /* ModuleDeclaration */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 262 /* SourceFile */: + case 233 /* CaseBlock */: + case 257 /* CatchClause */: + case 231 /* ModuleDeclaration */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: case 150 /* Constructor */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return true; - case 204 /* Block */: + case 205 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6891,7 +6911,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204 /* Block */) { + if (node.body && node.body.kind === 205 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6905,7 +6925,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -6914,20 +6934,20 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 225 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: errorNode = node.name; break; case 185 /* ArrowFunction */: @@ -6953,7 +6973,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 /* EnumDeclaration */ && isConst(node); + return node.kind === 230 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6970,7 +6990,7 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 /* ExpressionStatement */ + return node.kind === 208 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -7053,9 +7073,9 @@ var ts; case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 144 /* Parameter */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return node === parent_1.type; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 150 /* Constructor */: @@ -7081,29 +7101,43 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 190 /* PrefixUnaryExpression */; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // Warning: This has the same semantics as the forEach family of functions, // in that traversal terminates in the event that 'visitor' supplies a truthy value. function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitor(node); - case 232 /* CaseBlock */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 254 /* DefaultClause */: - case 219 /* LabeledStatement */: - case 221 /* TryStatement */: - case 256 /* CatchClause */: + case 233 /* CaseBlock */: + case 205 /* Block */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 218 /* WithStatement */: + case 219 /* SwitchStatement */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: + case 220 /* LabeledStatement */: + case 222 /* TryStatement */: + case 257 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7119,11 +7153,11 @@ var ts; if (operand) { traverse(operand); } - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 226 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be @@ -7170,13 +7204,13 @@ var ts; if (node) { switch (node.kind) { case 174 /* BindingElement */: - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 144 /* Parameter */: - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 258 /* ShorthandPropertyAssignment */: - case 223 /* VariableDeclaration */: + case 259 /* ShorthandPropertyAssignment */: + case 224 /* VariableDeclaration */: return true; } } @@ -7188,7 +7222,7 @@ var ts; } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); + return node && (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7199,7 +7233,7 @@ var ts; switch (kind) { case 150 /* Constructor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -7222,7 +7256,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return true; } @@ -7231,20 +7265,32 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: return true; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 220 /* LabeledStatement */) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 205 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { @@ -7323,9 +7369,9 @@ var ts; continue; } // Fall through - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 149 /* MethodDeclaration */: @@ -7336,13 +7382,26 @@ var ts; case 153 /* CallSignature */: case 154 /* ConstructSignature */: case 155 /* IndexSignature */: - case 229 /* EnumDeclaration */: - case 261 /* SourceFile */: + case 230 /* EnumDeclaration */: + case 262 /* SourceFile */: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, /*includeArrowFunctions*/ false); + if (container) { + switch (container.kind) { + case 150 /* Constructor */: + case 226 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; /** * Given an super call/property node, returns the closest node where * - a super call/property access is legal in the node and not legal in the parent node the node. @@ -7361,7 +7420,7 @@ var ts; case 142 /* ComputedPropertyName */: node = node.parent; break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: if (!stopOnFunctions) { @@ -7418,7 +7477,7 @@ var ts; function getEntityNameFromTypeNode(node) { switch (node.kind) { case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return node.typeName; case 199 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) @@ -7453,25 +7512,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // classes are valid targets return true; case 147 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 226 /* ClassDeclaration */; + return node.parent.kind === 227 /* ClassDeclaration */; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 149 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 226 /* ClassDeclaration */; + && node.parent.kind === 227 /* ClassDeclaration */; case 144 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return node.parent.body !== undefined && (node.parent.kind === 150 /* Constructor */ || node.parent.kind === 149 /* MethodDeclaration */ || node.parent.kind === 152 /* SetAccessor */) - && node.parent.parent.kind === 226 /* ClassDeclaration */; + && node.parent.parent.kind === 227 /* ClassDeclaration */; } return false; } @@ -7487,7 +7546,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); case 149 /* MethodDeclaration */: case 152 /* SetAccessor */: @@ -7497,9 +7556,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 /* JsxOpeningElement */ || - parent.kind === 247 /* JsxSelfClosingElement */ || - parent.kind === 249 /* JsxClosingElement */) { + if (parent.kind === 249 /* JsxOpeningElement */ || + parent.kind === 248 /* JsxSelfClosingElement */ || + parent.kind === 250 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7538,10 +7597,11 @@ var ts; case 194 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 198 /* OmittedExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: case 195 /* YieldExpression */: case 189 /* AwaitExpression */: + case 202 /* MetaProperty */: return true; case 141 /* QualifiedName */: while (node.parent.kind === 141 /* QualifiedName */) { @@ -7558,46 +7618,46 @@ var ts; case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: + case 261 /* EnumMember */: + case 258 /* PropertyAssignment */: case 174 /* BindingElement */: return parent_3.initializer === node; - case 207 /* ExpressionStatement */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 216 /* ReturnStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 220 /* ThrowStatement */: - case 218 /* SwitchStatement */: + case 208 /* ExpressionStatement */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 217 /* ReturnStatement */: + case 218 /* WithStatement */: + case 219 /* SwitchStatement */: + case 254 /* CaseClause */: + case 221 /* ThrowStatement */: + case 219 /* SwitchStatement */: return parent_3.expression === node; - case 211 /* ForStatement */: + case 212 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 225 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 225 /* VariableDeclarationList */) || forInStatement.expression === node; case 182 /* TypeAssertionExpression */: case 200 /* AsExpression */: return node === parent_3.expression; - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return node === parent_3.expression; case 142 /* ComputedPropertyName */: return node === parent_3.expression; case 145 /* Decorator */: - case 252 /* JsxExpression */: - case 251 /* JsxSpreadAttribute */: - case 259 /* SpreadAssignment */: + case 253 /* JsxExpression */: + case 252 /* JsxSpreadAttribute */: + case 260 /* SpreadAssignment */: return true; case 199 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); @@ -7617,7 +7677,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */; + return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7626,7 +7686,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 245 /* ExternalModuleReference */; + return node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 246 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7660,7 +7720,7 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 224 /* VariableDeclaration */) { var declaration = s.valueDeclaration; return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; } @@ -7713,35 +7773,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 245 /* ExternalModuleReference */) { + if (reference.kind === 246 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 241 /* ExportDeclaration */) { + if (node.kind === 242 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 231 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 238 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 /* ImportDeclaration */ + return node.kind === 236 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7752,8 +7812,8 @@ var ts; case 144 /* Parameter */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - case 258 /* ShorthandPropertyAssignment */: - case 257 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return node.questionToken !== undefined; @@ -7763,9 +7823,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 /* JSDocFunctionType */ && + return node.kind === 275 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 276 /* JSDocConstructorType */; + node.parameters[0].type.kind === 277 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -7778,7 +7838,7 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281 /* JSDocParameterTag */) { + if (doc.kind === 282 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } @@ -7810,9 +7870,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205 /* VariableStatement */; + parent.parent.parent.kind === 206 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205 /* VariableStatement */; + parent.parent.kind === 206 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7823,13 +7883,13 @@ var ts; var isSourceOfAssignmentExpressionStatement = parent && parent.parent && parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 207 /* ExpressionStatement */; + parent.parent.kind === 208 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 /* ModuleDeclaration */ && - parent && parent.kind === 230 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 257 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 231 /* ModuleDeclaration */ && + parent && parent.kind === 231 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 258 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } @@ -7848,18 +7908,18 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 282 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + return ts.filter(tags, function (tag) { return tag.kind === 282 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -7869,7 +7929,7 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283 /* JSDocTypeTag */); + var tag = getFirstJSDocTag(node, 284 /* JSDocTypeTag */); if (!tag && node.kind === 144 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { @@ -7880,15 +7940,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 281 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 283 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 285 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -7901,8 +7961,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 275 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 276 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 276 /* JSDocVariadicType */; })) { return true; } } @@ -7932,20 +7992,20 @@ var ts; case 191 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; case 183 /* ParenthesizedExpression */: case 175 /* ArrayLiteralExpression */: case 196 /* SpreadElement */: node = parent; break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } // Fall through - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: node = parent.parent; break; default: @@ -7962,6 +8022,18 @@ var ts; return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped + function isDeleteTarget(node) { + if (node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + return false; + } + node = node.parent; + while (node && node.kind === 183 /* ParenthesizedExpression */) { + node = node.parent; + } + return node && node.kind === 186 /* DeleteExpression */; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -7973,7 +8045,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 261 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 262 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7987,7 +8059,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 /* ImportSpecifier */ || parent.kind === 243 /* ExportSpecifier */) { + if (parent.kind === 240 /* ImportSpecifier */ || parent.kind === 244 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8014,8 +8086,8 @@ var ts; case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: + case 261 /* EnumMember */: + case 258 /* PropertyAssignment */: case 177 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; @@ -8029,10 +8101,10 @@ var ts; } return false; case 174 /* BindingElement */: - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8048,13 +8120,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 233 /* NamespaceExportDeclaration */ || - node.kind === 236 /* ImportClause */ && !!node.name || - node.kind === 237 /* NamespaceImport */ || - node.kind === 239 /* ImportSpecifier */ || - node.kind === 243 /* ExportSpecifier */ || - node.kind === 240 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 235 /* ImportEqualsDeclaration */ || + node.kind === 234 /* NamespaceExportDeclaration */ || + node.kind === 237 /* ImportClause */ && !!node.name || + node.kind === 238 /* NamespaceImport */ || + node.kind === 240 /* ImportSpecifier */ || + node.kind === 244 /* ExportSpecifier */ || + node.kind === 241 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8249,13 +8321,13 @@ var ts; var kind = node.kind; return kind === 150 /* Constructor */ || kind === 184 /* FunctionExpression */ - || kind === 225 /* FunctionDeclaration */ + || kind === 226 /* FunctionDeclaration */ || kind === 185 /* ArrowFunction */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ - || kind === 230 /* ModuleDeclaration */ - || kind === 261 /* SourceFile */; + || kind === 231 /* ModuleDeclaration */ + || kind === 262 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8387,14 +8459,13 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 197 /* ClassExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: case 194 /* TemplateExpression */: case 183 /* ParenthesizedExpression */: case 198 /* OmittedExpression */: - case 297 /* RawExpression */: return 19; case 181 /* TaggedTemplateExpression */: case 177 /* PropertyAccessExpression */: @@ -8578,13 +8649,12 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -9638,8 +9708,8 @@ var ts; var parseNode = getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9660,7 +9730,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 227 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9725,6 +9795,10 @@ var ts; return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 188 /* VoidExpression */; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return isIdentifier(node) && node.autoGenerateKind > 0 /* None */; @@ -9797,18 +9871,18 @@ var ts; || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ || kind === 155 /* IndexSignature */ - || kind === 203 /* SemicolonClassElement */; + || kind === 204 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 /* PropertyAssignment */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 259 /* SpreadAssignment */ + return kind === 258 /* PropertyAssignment */ + || kind === 259 /* ShorthandPropertyAssignment */ + || kind === 260 /* SpreadAssignment */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */ - || kind === 244 /* MissingDeclaration */; + || kind === 245 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -9871,7 +9945,7 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 174 /* BindingElement */: return true; @@ -9959,8 +10033,8 @@ var ts; || kind === 178 /* ElementAccessExpression */ || kind === 180 /* NewExpression */ || kind === 179 /* CallExpression */ - || kind === 246 /* JsxElement */ - || kind === 247 /* JsxSelfClosingElement */ + || kind === 247 /* JsxElement */ + || kind === 248 /* JsxSelfClosingElement */ || kind === 181 /* TaggedTemplateExpression */ || kind === 175 /* ArrayLiteralExpression */ || kind === 183 /* ParenthesizedExpression */ @@ -9979,7 +10053,7 @@ var ts; || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ || kind === 201 /* NonNullExpression */ - || kind === 297 /* RawExpression */; + || kind === 202 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10007,7 +10081,6 @@ var ts; || kind === 196 /* SpreadElement */ || kind === 200 /* AsExpression */ || kind === 198 /* OmittedExpression */ - || kind === 297 /* RawExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10021,11 +10094,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294 /* PartiallyEmittedExpression */; + return node.kind === 295 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293 /* NotEmittedStatement */; + return node.kind === 294 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10039,12 +10112,12 @@ var ts; ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 202 /* TemplateSpan */; + return node.kind === 203 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 204 /* Block */; + return node.kind === 205 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10062,121 +10135,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223 /* VariableDeclaration */; + return node.kind === 224 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224 /* VariableDeclarationList */; + return node.kind === 225 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232 /* CaseBlock */; + return node.kind === 233 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 /* ModuleBlock */ - || kind === 230 /* ModuleDeclaration */; + return kind === 232 /* ModuleBlock */ + || kind === 231 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */; + return node.kind === 235 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236 /* ImportClause */; + return node.kind === 237 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 /* NamedImports */ - || kind === 237 /* NamespaceImport */; + return kind === 239 /* NamedImports */ + || kind === 238 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239 /* ImportSpecifier */; + return node.kind === 240 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242 /* NamedExports */; + return node.kind === 243 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243 /* ExportSpecifier */; + return node.kind === 244 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 /* ModuleDeclaration */ || node.kind === 229 /* EnumDeclaration */; + return node.kind === 231 /* ModuleDeclaration */ || node.kind === 230 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { return kind === 185 /* ArrowFunction */ || kind === 174 /* BindingElement */ - || kind === 226 /* ClassDeclaration */ + || kind === 227 /* ClassDeclaration */ || kind === 197 /* ClassExpression */ || kind === 150 /* Constructor */ - || kind === 229 /* EnumDeclaration */ - || kind === 260 /* EnumMember */ - || kind === 243 /* ExportSpecifier */ - || kind === 225 /* FunctionDeclaration */ + || kind === 230 /* EnumDeclaration */ + || kind === 261 /* EnumMember */ + || kind === 244 /* ExportSpecifier */ + || kind === 226 /* FunctionDeclaration */ || kind === 184 /* FunctionExpression */ || kind === 151 /* GetAccessor */ - || kind === 236 /* ImportClause */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 239 /* ImportSpecifier */ - || kind === 227 /* InterfaceDeclaration */ + || kind === 237 /* ImportClause */ + || kind === 235 /* ImportEqualsDeclaration */ + || kind === 240 /* ImportSpecifier */ + || kind === 228 /* InterfaceDeclaration */ || kind === 149 /* MethodDeclaration */ || kind === 148 /* MethodSignature */ - || kind === 230 /* ModuleDeclaration */ - || kind === 233 /* NamespaceExportDeclaration */ - || kind === 237 /* NamespaceImport */ + || kind === 231 /* ModuleDeclaration */ + || kind === 234 /* NamespaceExportDeclaration */ + || kind === 238 /* NamespaceImport */ || kind === 144 /* Parameter */ - || kind === 257 /* PropertyAssignment */ + || kind === 258 /* PropertyAssignment */ || kind === 147 /* PropertyDeclaration */ || kind === 146 /* PropertySignature */ || kind === 152 /* SetAccessor */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 228 /* TypeAliasDeclaration */ + || kind === 259 /* ShorthandPropertyAssignment */ + || kind === 229 /* TypeAliasDeclaration */ || kind === 143 /* TypeParameter */ - || kind === 223 /* VariableDeclaration */ - || kind === 285 /* JSDocTypedefTag */; + || kind === 224 /* VariableDeclaration */ + || kind === 286 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 225 /* FunctionDeclaration */ - || kind === 244 /* MissingDeclaration */ - || kind === 226 /* ClassDeclaration */ - || kind === 227 /* InterfaceDeclaration */ - || kind === 228 /* TypeAliasDeclaration */ - || kind === 229 /* EnumDeclaration */ - || kind === 230 /* ModuleDeclaration */ - || kind === 235 /* ImportDeclaration */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 241 /* ExportDeclaration */ - || kind === 240 /* ExportAssignment */ - || kind === 233 /* NamespaceExportDeclaration */; + return kind === 226 /* FunctionDeclaration */ + || kind === 245 /* MissingDeclaration */ + || kind === 227 /* ClassDeclaration */ + || kind === 228 /* InterfaceDeclaration */ + || kind === 229 /* TypeAliasDeclaration */ + || kind === 230 /* EnumDeclaration */ + || kind === 231 /* ModuleDeclaration */ + || kind === 236 /* ImportDeclaration */ + || kind === 235 /* ImportEqualsDeclaration */ + || kind === 242 /* ExportDeclaration */ + || kind === 241 /* ExportAssignment */ + || kind === 234 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 /* BreakStatement */ - || kind === 214 /* ContinueStatement */ - || kind === 222 /* DebuggerStatement */ - || kind === 209 /* DoStatement */ - || kind === 207 /* ExpressionStatement */ - || kind === 206 /* EmptyStatement */ - || kind === 212 /* ForInStatement */ - || kind === 213 /* ForOfStatement */ - || kind === 211 /* ForStatement */ - || kind === 208 /* IfStatement */ - || kind === 219 /* LabeledStatement */ - || kind === 216 /* ReturnStatement */ - || kind === 218 /* SwitchStatement */ - || kind === 220 /* ThrowStatement */ - || kind === 221 /* TryStatement */ - || kind === 205 /* VariableStatement */ - || kind === 210 /* WhileStatement */ - || kind === 217 /* WithStatement */ - || kind === 293 /* NotEmittedStatement */ - || kind === 296 /* EndOfDeclarationMarker */ - || kind === 295 /* MergeDeclarationMarker */; + return kind === 216 /* BreakStatement */ + || kind === 215 /* ContinueStatement */ + || kind === 223 /* DebuggerStatement */ + || kind === 210 /* DoStatement */ + || kind === 208 /* ExpressionStatement */ + || kind === 207 /* EmptyStatement */ + || kind === 213 /* ForInStatement */ + || kind === 214 /* ForOfStatement */ + || kind === 212 /* ForStatement */ + || kind === 209 /* IfStatement */ + || kind === 220 /* LabeledStatement */ + || kind === 217 /* ReturnStatement */ + || kind === 219 /* SwitchStatement */ + || kind === 221 /* ThrowStatement */ + || kind === 222 /* TryStatement */ + || kind === 206 /* VariableStatement */ + || kind === 211 /* WhileStatement */ + || kind === 218 /* WithStatement */ + || kind === 294 /* NotEmittedStatement */ + || kind === 297 /* EndOfDeclarationMarker */ + || kind === 296 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10197,24 +10270,24 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204 /* Block */; + || kind === 205 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 245 /* ExternalModuleReference */ + return kind === 246 /* ExternalModuleReference */ || kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 248 /* JsxOpeningElement */; + return node.kind === 249 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249 /* JsxClosingElement */; + return node.kind === 250 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { @@ -10226,64 +10299,64 @@ var ts; ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 /* JsxElement */ - || kind === 252 /* JsxExpression */ - || kind === 247 /* JsxSelfClosingElement */ + return kind === 247 /* JsxElement */ + || kind === 253 /* JsxExpression */ + || kind === 248 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 /* JsxAttribute */ - || kind === 251 /* JsxSpreadAttribute */; + return kind === 251 /* JsxAttribute */ + || kind === 252 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251 /* JsxSpreadAttribute */; + return node.kind === 252 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250 /* JsxAttribute */; + return node.kind === 251 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 252 /* JsxExpression */; + || kind === 253 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 /* CaseClause */ - || kind === 254 /* DefaultClause */; + return kind === 254 /* CaseClause */ + || kind === 255 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255 /* HeritageClause */; + return node.kind === 256 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256 /* CatchClause */; + return node.kind === 257 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 257 /* PropertyAssignment */; + return node.kind === 258 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258 /* ShorthandPropertyAssignment */; + return node.kind === 259 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 261 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 261 /* SourceFile */; + return node.kind === 262 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10515,7 +10588,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 143 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 228 /* InterfaceDeclaration */) { return current; } } @@ -10535,14 +10608,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 225 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 206 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10558,14 +10631,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 225 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 206 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10634,7 +10707,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 /* SourceFile */ + var ConstructorForKind = kind === 262 /* SourceFile */ ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -11351,7 +11424,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(202 /* TemplateSpan */, location); + var node = createNode(203 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -11366,7 +11439,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(204 /* Block */, location, flags); + var block = createNode(205 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11382,7 +11455,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205 /* VariableStatement */, location, flags); + var node = createNode(206 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11397,7 +11470,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224 /* VariableDeclarationList */, location, flags); + var node = createNode(225 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11410,7 +11483,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223 /* VariableDeclaration */, location, flags); + var node = createNode(224 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11425,11 +11498,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(206 /* EmptyStatement */, location); + return createNode(207 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(207 /* ExpressionStatement */, location, flags); + var node = createNode(208 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11442,7 +11515,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208 /* IfStatement */, location); + var node = createNode(209 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11457,7 +11530,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(209 /* DoStatement */, location); + var node = createNode(210 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11471,7 +11544,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(210 /* WhileStatement */, location); + var node = createNode(211 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11485,7 +11558,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(212 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11501,7 +11574,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(212 /* ForInStatement */, location); + var node = createNode(213 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11516,7 +11589,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(213 /* ForOfStatement */, location); + var node = createNode(214 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11531,7 +11604,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(214 /* ContinueStatement */, location); + var node = createNode(215 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11546,7 +11619,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(215 /* BreakStatement */, location); + var node = createNode(216 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11561,7 +11634,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(216 /* ReturnStatement */, location); + var node = createNode(217 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11574,7 +11647,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(217 /* WithStatement */, location); + var node = createNode(218 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11588,7 +11661,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(218 /* SwitchStatement */, location); + var node = createNode(219 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11602,7 +11675,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(219 /* LabeledStatement */, location); + var node = createNode(220 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11616,7 +11689,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(220 /* ThrowStatement */, location); + var node = createNode(221 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11629,7 +11702,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221 /* TryStatement */, location); + var node = createNode(222 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11644,7 +11717,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(232 /* CaseBlock */, location); + var node = createNode(233 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11657,7 +11730,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225 /* FunctionDeclaration */, location, flags); + var node = createNode(226 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11677,7 +11750,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226 /* ClassDeclaration */, location); + var node = createNode(227 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11695,7 +11768,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235 /* ImportDeclaration */, location); + var node = createNode(236 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11711,7 +11784,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(236 /* ImportClause */, location); + var node = createNode(237 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11725,7 +11798,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(237 /* NamespaceImport */, location); + var node = createNode(238 /* NamespaceImport */, location); node.name = name; return node; } @@ -11738,7 +11811,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(238 /* NamedImports */, location); + var node = createNode(239 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11751,7 +11824,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(239 /* ImportSpecifier */, location); + var node = createNode(240 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11765,7 +11838,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240 /* ExportAssignment */, location); + var node = createNode(241 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11781,7 +11854,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241 /* ExportDeclaration */, location); + var node = createNode(242 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11797,7 +11870,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(242 /* NamedExports */, location); + var node = createNode(243 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11810,7 +11883,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(243 /* ExportSpecifier */, location); + var node = createNode(244 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11825,7 +11898,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246 /* JsxElement */, location); + var node = createNode(247 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11840,7 +11913,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247 /* JsxSelfClosingElement */, location); + var node = createNode(248 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11854,7 +11927,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248 /* JsxOpeningElement */, location); + var node = createNode(249 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11868,7 +11941,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(249 /* JsxClosingElement */, location); + var node = createNode(250 /* JsxClosingElement */, location); node.tagName = tagName; return node; } @@ -11881,7 +11954,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(250 /* JsxAttribute */, location); + var node = createNode(251 /* JsxAttribute */, location); node.name = name; node.initializer = initializer; return node; @@ -11895,7 +11968,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(251 /* JsxSpreadAttribute */, location); + var node = createNode(252 /* JsxSpreadAttribute */, location); node.expression = expression; return node; } @@ -11907,22 +11980,23 @@ var ts; return node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252 /* JsxExpression */, location); + function createJsxExpression(expression, dotDotDotToken, location) { + var node = createNode(253 /* JsxExpression */, location); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); + return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); } return node; } ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types, location) { - var node = createNode(255 /* HeritageClause */, location); + var node = createNode(256 /* HeritageClause */, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11936,7 +12010,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(253 /* CaseClause */, location); + var node = createNode(254 /* CaseClause */, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11950,7 +12024,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(254 /* DefaultClause */, location); + var node = createNode(255 /* DefaultClause */, location); node.statements = createNodeArray(statements); return node; } @@ -11963,7 +12037,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256 /* CatchClause */, location); + var node = createNode(257 /* CatchClause */, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11978,7 +12052,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer, location) { - var node = createNode(257 /* PropertyAssignment */, location); + var node = createNode(258 /* PropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11993,14 +12067,14 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258 /* ShorthandPropertyAssignment */, location); + var node = createNode(259 /* ShorthandPropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; function createSpreadAssignment(expression, location) { - var node = createNode(259 /* SpreadAssignment */, location); + var node = createNode(260 /* SpreadAssignment */, location); node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } @@ -12022,7 +12096,7 @@ var ts; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261 /* SourceFile */, /*location*/ node, node.flags); + var updated = createNode(262 /* SourceFile */, /*location*/ node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12089,7 +12163,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(293 /* NotEmittedStatement */, /*location*/ original); + var node = createNode(294 /* NotEmittedStatement */, /*location*/ original); node.original = original; return node; } @@ -12099,7 +12173,7 @@ var ts; * order to properly emit exports. */ function createEndOfDeclarationMarker(original) { - var node = createNode(296 /* EndOfDeclarationMarker */); + var node = createNode(297 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12110,7 +12184,7 @@ var ts; * order to properly emit exports. */ function createMergeDeclarationMarker(original) { - var node = createNode(295 /* MergeDeclarationMarker */); + var node = createNode(296 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12125,7 +12199,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294 /* PartiallyEmittedExpression */, /*location*/ location || original); + var node = createNode(295 /* PartiallyEmittedExpression */, /*location*/ location || original); node.expression = expression; node.original = original; return node; @@ -12138,19 +12212,6 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - /** - * Creates a node that emits a string of raw text in an expression position. Raw text is never - * transformed, should be ES3 compliant, and should have the same precedence as - * PrimaryExpression. - * - * @param text The raw text of the node. - */ - function createRawExpression(text) { - var node = createNode(297 /* RawExpression */); - node.text = text; - return node; - } - ts.createRawExpression = createRawExpression; // Compound nodes function createComma(left, right) { return createBinary(left, 25 /* CommaToken */, right); @@ -12326,6 +12387,20 @@ var ts; return setEmitFlags(createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; + // Utilities + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 220 /* LabeledStatement */ + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12432,9 +12507,9 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 149 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -12999,7 +13074,7 @@ var ts; case 177 /* PropertyAccessExpression */: node = node.expression; continue; - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13054,7 +13129,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294 /* PartiallyEmittedExpression */) { + while (node.kind === 295 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13133,7 +13208,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -13391,10 +13466,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 236 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 241 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 242 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -13514,7 +13589,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13526,11 +13601,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13567,7 +13642,7 @@ var ts; // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; case 196 /* SpreadElement */: - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13591,7 +13666,7 @@ var ts; : propertyName; } break; - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13603,7 +13678,7 @@ var ts; : propertyName; } break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13717,20 +13792,20 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 234 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + case 235 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -13760,13 +13835,13 @@ var ts; } } break; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13774,7 +13849,7 @@ var ts; } } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -13794,7 +13869,7 @@ var ts; } } break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -13847,7 +13922,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261 /* SourceFile */) { + if (kind === 262 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { @@ -13903,20 +13978,20 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 223 /* VariableDeclaration */: + case 258 /* PropertyAssignment */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -13942,7 +14017,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -14034,6 +14109,8 @@ var ts; visitNode(cbNode, node.type); case 201 /* NonNullExpression */: return visitNode(cbNode, node.expression); + case 202 /* MetaProperty */: + return visitNode(cbNode, node.name); case 193 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || @@ -14042,76 +14119,76 @@ var ts; visitNode(cbNode, node.whenFalse); case 196 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: return visitNode(cbNode, node.label); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 253 /* CaseClause */: + case 254 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 145 /* Decorator */: return visitNode(cbNode, node.expression); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || @@ -14119,155 +14196,156 @@ var ts; visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 194 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 142 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return visitNodes(cbNodes, node.types); case 199 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245 /* ExternalModuleReference */: + case 246 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 252 /* JsxExpression */: - return visitNode(cbNode, node.expression); - case 249 /* JsxClosingElement */: + case 253 /* JsxExpression */: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 250 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 262 /* JSDocTypeExpression */: + case 263 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 266 /* JSDocUnionType */: + case 267 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 267 /* JSDocTupleType */: + case 268 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 265 /* JSDocArrayType */: + case 266 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 269 /* JSDocNonNullableType */: + case 270 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 268 /* JSDocNullableType */: + case 269 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 270 /* JSDocRecordType */: + case 271 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273 /* JSDocOptionalType */: + case 274 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275 /* JSDocVariadicType */: + case 276 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 276 /* JSDocConstructorType */: + case 277 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 277 /* JSDocThisType */: + case 278 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 271 /* JSDocRecordMember */: + case 272 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278 /* JSDocComment */: + case 279 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 281 /* JSDocParameterTag */: + case 282 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282 /* JSDocReturnTag */: + case 283 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 283 /* JSDocTypeTag */: + case 284 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 280 /* JSDocAugmentsTag */: + case 281 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocTemplateTag */: + case 285 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287 /* JSDocTypeLiteral */: + case 288 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286 /* JSDocPropertyTag */: + case 287 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 288 /* JSDocLiteralType */: + case 289 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14539,7 +14617,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(262 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -15327,7 +15405,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 147 /* PropertyDeclaration */: - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return true; case 149 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -15344,8 +15422,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: return true; } } @@ -15354,42 +15432,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 205 /* VariableStatement */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 207 /* ExpressionStatement */: - case 220 /* ThrowStatement */: - case 216 /* ReturnStatement */: - case 218 /* SwitchStatement */: - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 206 /* EmptyStatement */: - case 221 /* TryStatement */: - case 219 /* LabeledStatement */: - case 209 /* DoStatement */: - case 222 /* DebuggerStatement */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 226 /* FunctionDeclaration */: + case 206 /* VariableStatement */: + case 205 /* Block */: + case 209 /* IfStatement */: + case 208 /* ExpressionStatement */: + case 221 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 219 /* SwitchStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 212 /* ForStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: + case 207 /* EmptyStatement */: + case 222 /* TryStatement */: + case 220 /* LabeledStatement */: + case 210 /* DoStatement */: + case 223 /* DebuggerStatement */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: + case 241 /* ExportAssignment */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 229 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 261 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -15405,7 +15483,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223 /* VariableDeclaration */) { + if (node.kind !== 224 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15590,7 +15668,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202 /* TemplateSpan */); + var span = createNode(203 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -17179,8 +17257,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248 /* JsxOpeningElement */) { - var node = createNode(246 /* JsxElement */, opening.pos); + if (opening.kind === 249 /* JsxOpeningElement */) { + var node = createNode(247 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17190,7 +17268,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 248 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17264,7 +17342,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(248 /* JsxOpeningElement */, fullStart); + node = createNode(249 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -17276,7 +17354,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(247 /* JsxSelfClosingElement */, fullStart); + node = createNode(248 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17300,9 +17378,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252 /* JsxExpression */); + var node = createNode(253 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -17319,7 +17398,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250 /* JsxAttribute */); + var node = createNode(251 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -17334,7 +17413,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251 /* JsxSpreadAttribute */); + var node = createNode(252 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -17342,7 +17421,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249 /* JsxClosingElement */); + var node = createNode(250 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -17581,7 +17660,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(259 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(260 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17606,7 +17685,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(259 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -17617,7 +17696,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(258 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -17668,8 +17747,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180 /* NewExpression */); + var fullStart = scanner.getStartPos(); parseExpected(93 /* NewKeyword */); + if (parseOptional(22 /* DotToken */)) { + var node_1 = createNode(202 /* MetaProperty */, fullStart); + node_1.keywordToken = 93 /* NewKeyword */; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(180 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18 /* OpenParenToken */) { @@ -17679,7 +17765,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204 /* Block */); + var node = createNode(205 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17712,12 +17798,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206 /* EmptyStatement */); + var node = createNode(207 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(208 /* IfStatement */); + var node = createNode(209 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17727,7 +17813,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209 /* DoStatement */); + var node = createNode(210 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -17742,7 +17828,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210 /* WhileStatement */); + var node = createNode(211 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17765,21 +17851,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(212 /* ForInStatement */, pos); + var forInStatement = createNode(213 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else if (parseOptional(140 /* OfKeyword */)) { - var forOfStatement = createNode(213 /* ForOfStatement */, pos); + var forOfStatement = createNode(214 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211 /* ForStatement */, pos); + var forStatement = createNode(212 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -17797,7 +17883,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 216 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17805,7 +17891,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216 /* ReturnStatement */); + var node = createNode(217 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -17814,7 +17900,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217 /* WithStatement */); + var node = createNode(218 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17823,7 +17909,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253 /* CaseClause */); + var node = createNode(254 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -17831,7 +17917,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254 /* DefaultClause */); + var node = createNode(255 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -17841,12 +17927,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218 /* SwitchStatement */); + var node = createNode(219 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(232 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(233 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -17861,7 +17947,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(220 /* ThrowStatement */); + var node = createNode(221 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -17869,7 +17955,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(221 /* TryStatement */); + var node = createNode(222 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -17882,7 +17968,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256 /* CatchClause */); + var result = createNode(257 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17892,7 +17978,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222 /* DebuggerStatement */); + var node = createNode(223 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -17904,13 +17990,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(219 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(220 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(208 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -18091,9 +18177,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(214 /* ContinueStatement */); + return parseBreakOrContinueStatement(215 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(215 /* BreakStatement */); + return parseBreakOrContinueStatement(216 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -18175,7 +18261,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(244 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(245 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18248,7 +18334,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223 /* VariableDeclaration */); + var node = createNode(224 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18257,7 +18343,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224 /* VariableDeclarationList */); + var node = createNode(225 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -18295,7 +18381,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205 /* VariableStatement */, fullStart); + var node = createNode(206 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18303,7 +18389,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* FunctionDeclaration */, fullStart); + var node = createNode(226 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -18527,7 +18613,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(203 /* SemicolonClassElement */); + var result = createNode(204 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18568,7 +18654,7 @@ var ts; /*modifiers*/ undefined, 197 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 227 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -18612,7 +18698,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(255 /* HeritageClause */); + var node = createNode(256 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -18635,7 +18721,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227 /* InterfaceDeclaration */, fullStart); + var node = createNode(228 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -18646,7 +18732,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* TypeAliasDeclaration */, fullStart); + var node = createNode(229 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(136 /* TypeKeyword */); @@ -18662,13 +18748,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(260 /* EnumMember */, scanner.getStartPos()); + var node = createNode(261 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* EnumDeclaration */, fullStart); + var node = createNode(230 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -18683,7 +18769,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(232 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -18694,7 +18780,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(231 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -18708,7 +18794,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(231 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (token() === 139 /* GlobalKeyword */) { @@ -18755,7 +18841,7 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(234 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); @@ -18774,7 +18860,7 @@ var ts; // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(234 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(235 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -18785,7 +18871,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(235 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(236 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -18808,7 +18894,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(236 /* ImportClause */, fullStart); + var importClause = createNode(237 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -18818,7 +18904,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(238 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(239 /* NamedImports */); } return finishNode(importClause); } @@ -18828,7 +18914,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(245 /* ExternalModuleReference */); + var node = createNode(246 /* ExternalModuleReference */); parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -18851,7 +18937,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(237 /* NamespaceImport */); + var namespaceImport = createNode(238 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -18866,14 +18952,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 238 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 239 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243 /* ExportSpecifier */); + return parseImportOrExportSpecifier(244 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239 /* ImportSpecifier */); + return parseImportOrExportSpecifier(240 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18898,14 +18984,14 @@ var ts; else { node.name = identifierName; } - if (kind === 239 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 240 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241 /* ExportDeclaration */, fullStart); + var node = createNode(242 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { @@ -18913,7 +18999,7 @@ var ts; node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(243 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. @@ -18926,7 +19012,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240 /* ExportAssignment */, fullStart); + var node = createNode(241 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -19008,10 +19094,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */ - || node.kind === 235 /* ImportDeclaration */ - || node.kind === 240 /* ExportAssignment */ - || node.kind === 241 /* ExportDeclaration */ + || node.kind === 235 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 246 /* ExternalModuleReference */ + || node.kind === 236 /* ImportDeclaration */ + || node.kind === 241 /* ExportAssignment */ + || node.kind === 242 /* ExportDeclaration */ ? node : undefined; }); @@ -19086,7 +19172,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(262 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(263 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -19097,12 +19183,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(266 /* JSDocUnionType */, type.pos); + var unionType = createNode(267 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(273 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(274 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19113,20 +19199,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(265 /* JSDocArrayType */, type.pos); + var arrayType = createNode(266 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(268 /* JSDocNullableType */, type.pos); + var nullableType = createNode(269 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(269 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(270 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19178,27 +19264,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277 /* JSDocThisType */); + var result = createNode(278 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276 /* JSDocConstructorType */); + var result = createNode(277 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275 /* JSDocVariadicType */); + var result = createNode(276 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274 /* JSDocFunctionType */); + var result = createNode(275 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -19220,7 +19306,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272 /* JSDocTypeReference */); + var result = createNode(273 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -19261,18 +19347,18 @@ var ts; return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270 /* JSDocRecordType */); + var result = createNode(271 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269 /* JSDocNonNullableType */); + var result = createNode(270 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267 /* JSDocTupleType */); + var result = createNode(268 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -19286,7 +19372,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266 /* JSDocUnionType */); + var result = createNode(267 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -19302,12 +19388,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263 /* JSDocAllType */); + var result = createNode(264 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288 /* JSDocLiteralType */); + var result = createNode(289 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19330,11 +19416,11 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(264 /* JSDocUnknownType */, pos); + var result = createNode(265 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(268 /* JSDocNullableType */, pos); + var result = createNode(269 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19499,7 +19585,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(278 /* JSDocComment */, start); + var result = createNode(279 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19615,7 +19701,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279 /* JSDocTag */, atToken.pos); + var result = createNode(280 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19672,7 +19758,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281 /* JSDocParameterTag */, atToken.pos); + var result = createNode(282 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19683,20 +19769,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282 /* JSDocReturnTag */, atToken.pos); + var result = createNode(283 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283 /* JSDocTypeTag */, atToken.pos); + var result = createNode(284 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19711,7 +19797,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(287 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19720,7 +19806,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(281 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19729,7 +19815,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(286 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); @@ -19743,7 +19829,7 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 273 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { var name_14 = jsDocTypeReference.name; @@ -19761,7 +19847,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(288 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19802,7 +19888,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(230 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(231 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -19848,7 +19934,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 285 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' @@ -19872,7 +19958,7 @@ var ts; break; } } - var result = createNode(284 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(285 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20346,7 +20432,7 @@ var ts; if (position >= array.pos && position < array.end) { // position was in this array. Search through this array to see if we find a // viable element. - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -20392,16 +20478,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 229 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 231 /* ModuleBlock */) { + else if (node.kind === 232 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20420,7 +20506,7 @@ var ts; }); return state_1; } - else if (node.kind === 230 /* ModuleDeclaration */) { + else if (node.kind === 231 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -20561,7 +20647,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 231 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20596,9 +20682,9 @@ var ts; return "__new"; case 155 /* IndexSignature */: return "__index"; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return "__export"; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; case 192 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { @@ -20615,22 +20701,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: + case 226 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; case 144 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 274 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 275 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 206 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -20717,7 +20803,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 241 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20737,7 +20823,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 243 /* ExportSpecifier */ || (node.kind === 234 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 244 /* ExportSpecifier */ || (node.kind === 235 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20760,7 +20846,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 285 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 286 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -20847,7 +20933,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -20926,43 +21012,43 @@ var ts; return; } switch (node.kind) { - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: bindWhileStatement(node); break; - case 209 /* DoStatement */: + case 210 /* DoStatement */: bindDoStatement(node); break; - case 211 /* ForStatement */: + case 212 /* ForStatement */: bindForStatement(node); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 208 /* IfStatement */: + case 209 /* IfStatement */: bindIfStatement(node); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 221 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 221 /* TryStatement */: + case 222 /* TryStatement */: bindTryStatement(node); break; - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: bindSwitchStatement(node); break; - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: bindCaseBlock(node); break; - case 253 /* CaseClause */: + case 254 /* CaseClause */: bindCaseClause(node); break; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: bindLabeledStatement(node); break; case 190 /* PrefixUnaryExpression */: @@ -20980,7 +21066,7 @@ var ts; case 193 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; case 179 /* CallExpression */: @@ -21147,11 +21233,11 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* IfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: + case 209 /* IfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: return parent.expression === node; - case 211 /* ForStatement */: + case 212 /* ForStatement */: case 193 /* ConditionalExpression */: return parent.condition === node; } @@ -21215,7 +21301,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 220 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21252,7 +21338,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224 /* VariableDeclarationList */) { + if (node.initializer.kind !== 225 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21274,7 +21360,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216 /* ReturnStatement */) { + if (node.kind === 217 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21294,7 +21380,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 216 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21360,7 +21446,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 255 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21427,7 +21513,7 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 210 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); @@ -21459,13 +21545,13 @@ var ts; else if (node.kind === 176 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257 /* PropertyAssignment */) { + if (p.kind === 258 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258 /* ShorthandPropertyAssignment */) { + else if (p.kind === 259 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259 /* SpreadAssignment */) { + else if (p.kind === 260 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21565,7 +21651,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 /* ForInStatement */ || node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 213 /* ForInStatement */ || node.parent.parent.kind === 214 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -21595,28 +21681,28 @@ var ts; function getContainerFlags(node) { switch (node.kind) { case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: + case 271 /* JSDocRecordType */: return 1 /* IsContainer */; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 274 /* JSDocFunctionType */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 275 /* JSDocFunctionType */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: case 170 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 261 /* SourceFile */: + case 262 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 149 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: @@ -21629,17 +21715,17 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 147 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 256 /* CatchClause */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 232 /* CaseBlock */: + case 257 /* CatchClause */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 233 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 204 /* Block */: + case 205 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -21676,20 +21762,20 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 161 /* TypeLiteral */: case 176 /* ObjectLiteralExpression */: - case 227 /* InterfaceDeclaration */: - case 270 /* JSDocRecordType */: - case 287 /* JSDocTypeLiteral */: + case 228 /* InterfaceDeclaration */: + case 271 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the @@ -21706,11 +21792,11 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: - case 228 /* TypeAliasDeclaration */: + case 275 /* JSDocFunctionType */: + case 229 /* TypeAliasDeclaration */: case 170 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, @@ -21732,11 +21818,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 261 /* SourceFile */ || body.kind === 231 /* ModuleBlock */)) { + var body = node.kind === 262 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 262 /* SourceFile */ || body.kind === 232 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 /* ExportDeclaration */ || stat.kind === 240 /* ExportAssignment */) { + if (stat.kind === 242 /* ExportDeclaration */ || stat.kind === 241 /* ExportAssignment */) { return true; } } @@ -21829,7 +21915,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 260 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -21841,7 +21927,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ + var currentKind = prop.kind === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -21863,10 +21949,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21977,8 +22063,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 261 /* SourceFile */ && - blockScopeContainer.kind !== 230 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 262 /* SourceFile */ && + blockScopeContainer.kind !== 231 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22091,14 +22177,14 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 286 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 259 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); @@ -22131,7 +22217,7 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return checkStrictModeCatchClause(node); case 186 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); @@ -22141,7 +22227,7 @@ var ts; return checkStrictModePostfixUnaryExpression(node); case 190 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return checkStrictModeWithStatement(node); case 167 /* ThisType */: seenThisKeyword = true; @@ -22152,22 +22238,22 @@ var ts; return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); case 144 /* Parameter */: return bindParameter(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 271 /* JSDocRecordMember */: + case 272 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 286 /* JSDocPropertyTag */: + case 287 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 259 /* SpreadAssignment */: - case 251 /* JsxSpreadAttribute */: + case 260 /* SpreadAssignment */: + case 252 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { @@ -22192,7 +22278,7 @@ var ts; // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 150 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -22202,12 +22288,12 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); case 161 /* TypeLiteral */: case 170 /* MappedType */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 288 /* JSDocTypeLiteral */: + case 271 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); case 176 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); @@ -22221,46 +22307,46 @@ var ts; break; // Members of classes, interfaces, and modules case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 234 /* ImportEqualsDeclaration */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return bindImportClause(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return bindExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return bindExportAssignment(node); - case 261 /* SourceFile */: + case 262 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204 /* Block */: + case 205 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -22292,7 +22378,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 240 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 241 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22302,7 +22388,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261 /* SourceFile */) { + if (node.parent.kind !== 262 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -22357,7 +22443,7 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 225 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { + if (container.kind === 226 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); @@ -22405,7 +22491,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22541,13 +22627,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 206 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 207 /* EmptyStatement */) || // report error on class declarations - node.kind === 226 /* ClassDeclaration */ || + node.kind === 227 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 230 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 229 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 230 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -22561,7 +22647,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 /* VariableStatement */ || + (node.kind !== 206 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -22585,13 +22671,13 @@ var ts; return computeCallExpression(node, subtreeFlags); case 180 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); case 183 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); case 192 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 144 /* Parameter */: return computeParameter(node, subtreeFlags); @@ -22599,23 +22685,23 @@ var ts; return computeArrowFunction(node, subtreeFlags); case 184 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); case 197 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return computeCatchClause(node, subtreeFlags); case 199 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -22628,7 +22714,7 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); case 177 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); @@ -23113,8 +23199,8 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: case 182 /* TypeAssertionExpression */: case 200 /* AsExpression */: case 201 /* NonNullExpression */: @@ -23122,18 +23208,18 @@ var ts; // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 247 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: case 10 /* JsxText */: - case 249 /* JsxClosingElement */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - case 252 /* JsxExpression */: + case 250 /* JsxClosingElement */: + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: + case 253 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: // for-of might be ESNext if it has a rest destructuring transformFlags |= 8 /* AssertESNext */; // FALLTHROUGH @@ -23143,8 +23229,9 @@ var ts; case 15 /* TemplateTail */: case 194 /* TemplateExpression */: case 181 /* TaggedTemplateExpression */: - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: case 114 /* StaticKeyword */: + case 202 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -23176,8 +23263,8 @@ var ts; case 164 /* UnionType */: case 165 /* IntersectionType */: case 166 /* ParenthesizedType */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: case 167 /* ThisType */: case 168 /* TypeOperator */: case 169 /* IndexedAccessType */: @@ -23207,7 +23294,7 @@ var ts; case 196 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 96 /* SuperKeyword */: @@ -23266,23 +23353,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 216 /* ReturnStatement */: - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 217 /* ReturnStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23306,18 +23393,18 @@ var ts; case 180 /* NewExpression */: case 175 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; case 144 /* Parameter */: return 536872257 /* ParameterExcludes */; case 185 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return 539358529 /* ClassExcludes */; case 150 /* Constructor */: @@ -23339,12 +23426,12 @@ var ts; case 153 /* CallSignature */: case 154 /* ConstructSignature */: case 155 /* IndexSignature */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; case 176 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 256 /* CatchClause */: + case 257 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; case 172 /* ObjectBindingPattern */: case 173 /* ArrayBindingPattern */: @@ -23386,10 +23473,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - /** Create Resolved from a file with unknown extension. */ - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; @@ -23402,13 +23485,14 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + /** Reads from "main" or "types"/"typings" depending on `extensions`. */ + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2 /* DtsOnly */: - case 0 /* TypeScript */: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1 /* JavaScript */: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -23475,6 +23559,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -23535,7 +23620,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -23552,7 +23641,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -23605,31 +23695,134 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + /** + * At first this function add entry directory -> module resolution result to the table. + * Then it computes the set of parent folders for 'directory' that should have the same module resolution result + * and for every parent folder in set it adds entry: parent -> module resolution. . + * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. + * Set of parent folders that should have the same result will be: + * [ + * /a/b/c/d, /a/b/c, /a/b + * ] + * this means that request for module resolution from file in any of these folder will be immediately found in cache. + */ + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + // if entry is already in cache do nothing + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + // find common prefix between directory and resolved file name + // this common prefix should be the shorted path that has the same resolution + // directory: /a/b/c/d/e + // resolvedFileName: /a/b/foo.d.ts + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_5 = ts.getDirectoryPath(current); + if (parent_5 === current || directoryPathMap.contains(parent_5)) { + break; + } + directoryPathMap.set(parent_5, result); + current = parent_5; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + // find first position where directory and resolution differs + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + // find last directory separator before position i + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + // put result in per-module name cache + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -23822,34 +24015,34 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -23866,10 +24059,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -23908,11 +24124,11 @@ var ts; } } switch (extensions) { - case 2 /* DtsOnly */: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0 /* TypeScript */: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1 /* JavaScript */: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -23922,19 +24138,21 @@ var ts; } /** Return the file if it exists. */ function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -23943,18 +24161,23 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - // Note: this would allow a package.json to specify a ".js" file as typings. Maybe that should be forbidden. - return resolvedFromAnyFile(fromFile); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0 /* TypeScript */, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -23964,7 +24187,7 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results @@ -23972,70 +24195,116 @@ var ts; } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + /** True if `extension` is one of the supported `extensions`. */ + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNodeModulesWorker(2 /* DtsOnly */, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true, /*cache*/ undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1 /* JavaScript */) { - return loadModuleFromNodeModulesFolder(2 /* DtsOnly */, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0 /* TypeScript */) { + if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); } } } @@ -24052,10 +24321,17 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2 /* DtsOnly */, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + /** + * Wraps value to SearchResult. + * @returns undefined if value is undefined or { value } otherwise + */ + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { @@ -24142,9 +24418,11 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -24153,6 +24431,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -24177,7 +24456,8 @@ var ts; // we deliberately exclude augmentations // since we are only interested in declarations of the module itself return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -24281,6 +24561,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var TypeFacts; @@ -24501,7 +24782,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 230 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 231 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 231 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -24606,7 +24887,7 @@ var ts; return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 261 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 262 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -24662,9 +24943,21 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 223 /* VariableDeclaration */ || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 174 /* BindingElement */) { + // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) + var errorBindingElement = ts.getAncestor(usage, 174 /* BindingElement */); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 224 /* VariableDeclaration */), usage); + } + else if (declaration.kind === 224 /* VariableDeclaration */) { + // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) @@ -24673,9 +24966,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205 /* VariableStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 206 /* VariableStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -24684,8 +24977,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -24713,6 +25006,15 @@ var ts; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -24736,7 +25038,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 278 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 279 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || lastLocation.kind === 144 /* Parameter */ || @@ -24763,13 +25065,13 @@ var ts; } } switch (location.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 262 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports["default"]) { @@ -24792,7 +25094,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 243 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 244 /* ExportSpecifier */)) { break; } } @@ -24800,7 +25102,7 @@ var ts; break loop; } break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -24823,9 +25125,9 @@ var ts; } } break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -24854,7 +25156,7 @@ var ts; // case 142 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 228 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -24867,7 +25169,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; @@ -24960,7 +25262,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 234 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -25048,7 +25350,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -25069,10 +25371,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 235 /* ImportDeclaration */) { + while (node && node.kind !== 236 /* ImportDeclaration */) { node = node.parent; } return node; @@ -25082,7 +25384,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 246 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -25207,19 +25509,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return getTargetOfImportClause(node); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 233 /* NamespaceExportDeclaration */: + case 234 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -25266,11 +25568,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240 /* ExportAssignment */) { + if (node.kind === 241 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 243 /* ExportSpecifier */) { + else if (node.kind === 244 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -25298,14 +25600,16 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 234 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 235 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - // Resolves a qualified name and any involved aliases + /** + * Resolves a qualified name and any involved aliases. + */ function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) { if (ts.nodeIsMissing(name)) { return undefined; @@ -25626,11 +25930,11 @@ var ts; } } switch (location_1.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -25682,7 +25986,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -25722,7 +26026,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 244 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -25821,7 +26125,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25867,7 +26171,7 @@ var ts; meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 177 /* PropertyAccessExpression */ || - entityName.parent.kind === 234 /* ImportEqualsDeclaration */) { + entityName.parent.kind === 235 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -25966,7 +26270,7 @@ var ts; while (node.kind === 166 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -25974,7 +26278,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 /* ModuleBlock */ && + node.parent.kind === 232 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -26066,9 +26370,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -26218,14 +26522,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -26291,7 +26595,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 /* SourceFile */ || declaration.parent.kind === 231 /* ModuleBlock */; + return declaration.parent.kind === 262 /* SourceFile */ || declaration.parent.kind === 232 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -26305,25 +26609,6 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); - writeSpace(writer); - } - writePunctuation(writer, 20 /* OpenBracketToken */); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21 /* CloseBracketToken */); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeType(info.type, 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130 /* ReadonlyKeyword */); @@ -26407,8 +26692,8 @@ var ts; writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 132 /* NumberKeyword */); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0 /* String */, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1 /* Number */, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -26588,6 +26873,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 /* SuppressAnyReturnType */ && isTypeAny(returnType)) { + return; + } if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); writePunctuation(writer, 35 /* EqualsGreaterThanToken */); @@ -26600,7 +26889,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -26620,6 +26908,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 20 /* OpenBracketToken */); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + switch (kind) { + case 1 /* Number */: + writeKeyword(writer, 132 /* NumberKeyword */); + break; + case 0 /* String */: + writeKeyword(writer, 134 /* StringKeyword */); + break; + } + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24 /* SemicolonToken */); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -26630,6 +26944,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -26646,32 +26961,32 @@ var ts; switch (node.kind) { case 174 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 225 /* FunctionDeclaration */: - case 229 /* EnumDeclaration */: - case 234 /* ImportEqualsDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 226 /* FunctionDeclaration */: + case 230 /* EnumDeclaration */: + case 235 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 234 /* ImportEqualsDeclaration */ && parent_7.kind !== 261 /* SourceFile */ && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 235 /* ImportEqualsDeclaration */ && parent_8.kind !== 262 /* SourceFile */ && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_7); + return isDeclarationVisible(parent_8); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 151 /* GetAccessor */: @@ -26688,7 +27003,7 @@ var ts; case 153 /* CallSignature */: case 155 /* IndexSignature */: case 144 /* Parameter */: - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: case 158 /* FunctionType */: case 159 /* ConstructorType */: case 161 /* TypeLiteral */: @@ -26701,18 +27016,18 @@ var ts; return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: return false; // Type parameters are always visible case 143 /* TypeParameter */: // Source file and namespace export are always visible - case 261 /* SourceFile */: - case 233 /* NamespaceExportDeclaration */: + case 262 /* SourceFile */: + case 234 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return false; default: return false; @@ -26721,10 +27036,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 241 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243 /* ExportSpecifier */) { + else if (node.parent.kind === 244 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -26817,12 +27132,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223 /* VariableDeclaration */: - case 224 /* VariableDeclarationList */: - case 239 /* ImportSpecifier */: - case 238 /* NamedImports */: - case 237 /* NamespaceImport */: - case 236 /* ImportClause */: + case 224 /* VariableDeclaration */: + case 225 /* VariableDeclarationList */: + case 240 /* ImportSpecifier */: + case 239 /* NamedImports */: + case 238 /* NamespaceImport */: + case 237 /* ImportClause */: node = node.parent; break; default: @@ -26846,9 +27161,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192 /* Never */) !== 0; - } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node) { @@ -27007,11 +27319,11 @@ var ts; } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 212 /* ForInStatement */) { + if (declaration.parent.parent.kind === 213 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 214 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -27026,7 +27338,7 @@ var ts; return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 223 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 224 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27074,7 +27386,7 @@ var ts; return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 258 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 259 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27177,7 +27489,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - if (declaration.kind === 257 /* PropertyAssignment */) { + if (declaration.kind === 258 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27210,10 +27522,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 240 /* ExportAssignment */) { + if (declaration.kind === 241 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 287 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27443,8 +27755,8 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || - node.kind === 225 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || + if (node.kind === 227 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || + node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { @@ -27455,7 +27767,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -27464,8 +27776,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 226 /* ClassDeclaration */ || - node.kind === 197 /* ClassExpression */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */ || node.kind === 227 /* ClassDeclaration */ || + node.kind === 197 /* ClassExpression */ || node.kind === 229 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -27497,11 +27809,13 @@ var ts; } return signatures; } - // The base constructor of a class can resolve to - // undefinedType if the class has no extends clause, - // unknownType if an error occurred during resolution of the extends expression, - // nullType if the extends expression is the null value, or - // an object type with at least one construct signature. + /** + * The base constructor of a class can resolve to + * * undefinedType if the class has no extends clause, + * * unknownType if an error occurred during resolution of the extends expression, + * * nullType if the extends expression is the null value, or + * * an object type with at least one construct signature. + */ function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -27616,7 +27930,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 228 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -27648,7 +27962,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 228 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -27705,7 +28019,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 286 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -27716,7 +28030,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 229 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -27750,7 +28064,7 @@ var ts; function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 230 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -27778,7 +28092,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 230 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -28176,6 +28490,9 @@ var ts; } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } + /** + * Converts an AnonymousType to a ResolvedType. + */ function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { @@ -28306,8 +28623,8 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -28618,7 +28935,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 273 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 274 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -28629,7 +28946,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 274 /* JSDocOptionalType */; } } } @@ -28685,7 +29002,7 @@ var ts; // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature @@ -28773,12 +29090,12 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: @@ -28789,7 +29106,7 @@ var ts; case 152 /* SetAccessor */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: + case 275 /* JSDocFunctionType */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -29080,7 +29397,7 @@ var ts; switch (node.kind) { case 157 /* TypeReference */: return node.typeName; - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return node.name; case 199 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other @@ -29108,7 +29425,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 272 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 273 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -29121,7 +29438,7 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272 /* JSDocTypeReference */) { + if (node.kind === 273 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); @@ -29163,9 +29480,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: return declaration; } } @@ -29358,8 +29675,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -29479,8 +29797,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; addTypeToIntersection(typeSet, type); } } @@ -29618,7 +29936,7 @@ var ts; getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -29745,7 +30063,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 229 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -29875,7 +30193,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 228 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -29894,8 +30212,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 263 /* JSDocAllType */: - case 264 /* JSDocUnknownType */: + case 264 /* JSDocAllType */: + case 265 /* JSDocUnknownType */: return anyType; case 134 /* StringKeyword */: return stringType; @@ -29913,21 +30231,21 @@ var ts; return nullType; case 129 /* NeverKeyword */: return neverType; - case 289 /* JSDocNullKeyword */: + case 290 /* JSDocNullKeyword */: return nullType; - case 290 /* JSDocUndefinedKeyword */: + case 291 /* JSDocUndefinedKeyword */: return undefinedType; - case 291 /* JSDocNeverKeyword */: + case 292 /* JSDocNeverKeyword */: return neverType; case 167 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); case 171 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 288 /* JSDocLiteralType */: + case 289 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 273 /* JSDocTypeReference */: return getTypeFromTypeReference(node); case 156 /* TypePredicate */: return booleanType; @@ -29936,29 +30254,29 @@ var ts; case 160 /* TypeQuery */: return getTypeFromTypeQueryNode(node); case 162 /* ArrayType */: - case 265 /* JSDocArrayType */: + case 266 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); case 163 /* TupleType */: return getTypeFromTupleTypeNode(node); case 164 /* UnionType */: - case 266 /* JSDocUnionType */: + case 267 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); case 165 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); case 166 /* ParenthesizedType */: - case 268 /* JSDocNullableType */: - case 269 /* JSDocNonNullableType */: - case 276 /* JSDocConstructorType */: - case 277 /* JSDocThisType */: - case 273 /* JSDocOptionalType */: + case 269 /* JSDocNullableType */: + case 270 /* JSDocNonNullableType */: + case 277 /* JSDocConstructorType */: + case 278 /* JSDocThisType */: + case 274 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 270 /* JSDocRecordType */: + case 271 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); case 158 /* FunctionType */: case 159 /* ConstructorType */: case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 274 /* JSDocFunctionType */: + case 288 /* JSDocTypeLiteral */: + case 275 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -29972,9 +30290,9 @@ var ts; case 141 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267 /* JSDocTupleType */: + case 268 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 275 /* JSDocVariadicType */: + case 276 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30136,17 +30454,19 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144 /* Index */) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384 /* TypeParameter */) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -30170,12 +30490,12 @@ var ts; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first // declaration since multiple declarations will all have the same parent anyway. - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { case 158 /* FunctionType */: case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: @@ -30186,10 +30506,10 @@ var ts; case 152 /* SetAccessor */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -30199,15 +30519,24 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 228 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: + case 275 /* JSDocFunctionType */: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 231 /* ModuleDeclaration */: + case 262 /* SourceFile */: return false; } node = node.parent; @@ -30217,7 +30546,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 /* SourceFile */ || parentKind === 231 /* ModuleBlock */; + return parentKind === 262 /* SourceFile */ || parentKind === 232 /* ModuleBlock */; } return false; } @@ -30309,7 +30638,7 @@ var ts; case 192 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return isContextSensitive(node.initializer); case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -30376,7 +30705,7 @@ var ts; // subtype of T but not structurally identical to T. This specifically means that two distinct but // structurally identical types (such as two classes) are not considered instances of each other. function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } /** * This is *not* a bi-directional relationship. @@ -30710,10 +31039,12 @@ var ts; } return false; } - // Compare two types and return - // Ternary.True if they are related with no assumptions, - // Ternary.Maybe if they are related with assumptions of other relationships, or - // Ternary.False if they are not related. + /** + * Compare two types and return + * * Ternary.True if they are related with no assumptions, + * * Ternary.Maybe if they are related with assumptions of other relationships, or + * * Ternary.False if they are not related. + */ function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { @@ -31177,8 +31508,11 @@ var ts; } } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1 /* True */; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { + return -1 /* True */; + } } return 0 /* False */; } @@ -31345,7 +31679,7 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; @@ -31584,8 +31918,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var t = types_8[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -31593,8 +31927,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -31700,8 +32034,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; result |= getFalsyFlags(t); } return result; @@ -31883,7 +32217,7 @@ var ts; case 174 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -32269,8 +32603,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32411,7 +32745,7 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && + (target.kind === 224 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; @@ -32516,8 +32850,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getTypeFacts(t); } return result; @@ -32605,7 +32939,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 257 /* PropertyAssignment */ ? + return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 258 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } @@ -32624,9 +32958,9 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return stringType; - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; case 192 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); @@ -32636,9 +32970,9 @@ var ts; return getAssignedTypeOfArrayLiteralElement(parent, node); case 196 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -32664,26 +32998,26 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212 /* ForInStatement */) { + if (node.parent.parent.kind === 213 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.parent.kind === 214 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 /* VariableDeclaration */ ? + return node.kind === 224 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? + return node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 /* VariableDeclaration */ && node.initializer && + return node.kind === 224 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); @@ -32710,7 +33044,7 @@ var ts; getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 254 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -32825,8 +33159,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33461,8 +33795,8 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 /* ModuleBlock */ || - node.kind === 261 /* SourceFile */ || + node.kind === 232 /* ModuleBlock */ || + node.kind === 262 /* SourceFile */ || node.kind === 147 /* PropertyDeclaration */) { return node; } @@ -33542,7 +33876,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration_1.kind === 226 /* ClassDeclaration */ + if (declaration_1.kind === 227 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -33573,6 +33907,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -33611,7 +33946,7 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph @@ -33646,7 +33981,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 256 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 257 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -33671,8 +34006,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 211 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 224 /* VariableDeclarationList */).parent === container && + if (container.kind === 212 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 225 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -33793,11 +34128,11 @@ var ts; needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; @@ -33861,9 +34196,9 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 275 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 278 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -34254,8 +34589,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -34338,13 +34673,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250 /* JsxAttribute */) { + if (attribute.kind === 251 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 251 /* JsxSpreadAttribute */) { + else if (attribute.kind === 252 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -34382,14 +34717,14 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 144 /* Parameter */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: case 174 /* BindingElement */: return getContextualTypeForInitializerExpression(node); case 185 /* ArrowFunction */: - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); case 195 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); @@ -34401,22 +34736,22 @@ var ts; return getTypeFromTypeNode(parent.type); case 192 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); case 175 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); case 193 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); case 183 /* ParenthesizedExpression */: return getContextualType(parent); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return getContextualType(parent); - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -34477,8 +34812,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -34683,18 +35018,18 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 /* PropertyAssignment */ || - memberDecl.kind === 258 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 258 /* PropertyAssignment */ || + memberDecl.kind === 259 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257 /* PropertyAssignment */) { + if (memberDecl.kind === 258 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } else if (memberDecl.kind === 149 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 259 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -34702,8 +35037,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 257 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 258 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 259 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -34731,7 +35066,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259 /* SpreadAssignment */) { + else if (memberDecl.kind === 260 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -34842,13 +35177,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: checkJsxExpression(child); break; - case 246 /* JsxElement */: + case 247 /* JsxElement */: checkJsxElement(child); break; - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -35223,11 +35558,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250 /* JsxAttribute */) { + if (node.attributes[i].kind === 251 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 251 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 252 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -35248,7 +35583,11 @@ var ts; } function checkJsxExpression(node) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -35276,7 +35615,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 223 /* VariableDeclaration */ ? + var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 224 /* VariableDeclaration */ ? node.name : node.right; if (left.kind === 96 /* SuperKeyword */) { @@ -35453,7 +35792,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer.kind === 225 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35482,7 +35821,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 /* ForInStatement */ && + if (node.kind === 213 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35591,13 +35930,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent_9; index = cutoffIndex; } } @@ -35605,7 +35944,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent_9; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -35909,7 +36248,7 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 145 /* Decorator */) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; @@ -35953,7 +36292,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); @@ -35998,7 +36337,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } @@ -36049,7 +36388,7 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 227 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } @@ -36554,7 +36893,7 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 144 /* Parameter */: @@ -36693,9 +37032,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 225 /* FunctionDeclaration */ + ? 226 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 223 /* VariableDeclaration */ + ? 224 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -36722,6 +37061,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 150 /* Constructor */) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -36863,7 +37219,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204 /* Block */) { + if (func.body.kind !== 205 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -36953,7 +37309,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 219 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -37015,7 +37371,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 205 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -37095,6 +37451,7 @@ var ts; if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } @@ -37115,7 +37472,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204 /* Block */) { + if (node.body.kind === 205 /* Block */) { checkSourceElement(node.body); } else { @@ -37184,7 +37541,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237 /* NamespaceImport */; + return declaration && declaration.kind === 238 /* NamespaceImport */; } } } @@ -37201,6 +37558,16 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 177 /* PropertyAccessExpression */ && expr.kind !== 178 /* ElementAccessExpression */) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { @@ -37276,8 +37643,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -37294,8 +37661,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -37304,8 +37671,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_18 = types; _a < types_18.length; _a++) { + var t = types_18[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -37363,7 +37730,7 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 /* PropertyAssignment */ || property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 258 /* PropertyAssignment */ || property.kind === 259 /* ShorthandPropertyAssignment */) { var name_20 = property.name; if (name_20.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(name_20); @@ -37378,7 +37745,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 259 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -37390,7 +37757,7 @@ var ts; error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); } } - else if (property.kind === 259 /* SpreadAssignment */) { + else if (property.kind === 260 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -37463,7 +37830,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 259 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -37493,7 +37860,7 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 /* SpreadAssignment */ ? + var error = target.parent.kind === 260 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -37530,8 +37897,8 @@ var ts; case 176 /* ObjectLiteralExpression */: case 187 /* TypeOfExpression */: case 201 /* NonNullExpression */: - case 247 /* JsxSelfClosingElement */: - case 246 /* JsxElement */: + case 248 /* JsxSelfClosingElement */: + case 247 /* JsxElement */: return true; case 193 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && @@ -38038,6 +38405,8 @@ var ts; return checkAssertion(node); case 201 /* NonNullExpression */: return checkNonNullAssertion(node); + case 202 /* MetaProperty */: + return checkMetaProperty(node); case 186 /* DeleteExpression */: return checkDeleteExpression(node); case 188 /* VoidExpression */: @@ -38058,13 +38427,13 @@ var ts; return undefinedWideningType; case 195 /* YieldExpression */: return checkYieldExpression(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return checkJsxExpression(node); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return checkJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -38118,7 +38487,7 @@ var ts; return false; } return node.kind === 149 /* MethodDeclaration */ || - node.kind === 225 /* FunctionDeclaration */ || + node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { @@ -38179,14 +38548,14 @@ var ts; switch (node.parent.kind) { case 185 /* ArrowFunction */: case 153 /* CallSignature */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 158 /* FunctionType */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -38215,7 +38584,7 @@ var ts; if (node.kind === 155 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 /* FunctionType */ || node.kind === 225 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || + else if (node.kind === 158 /* FunctionType */ || node.kind === 226 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -38349,7 +38718,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227 /* InterfaceDeclaration */) { + if (node.kind === 228 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -38445,7 +38814,7 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 225 /* FunctionDeclaration */) { + else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 226 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } @@ -38480,7 +38849,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38641,8 +39010,8 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 227 /* InterfaceDeclaration */ && - n.parent.kind !== 226 /* ClassDeclaration */ && + if (n.parent.kind !== 228 /* InterfaceDeclaration */ && + n.parent.kind !== 227 /* ClassDeclaration */ && n.parent.kind !== 197 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { @@ -38770,7 +39139,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 228 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -38781,7 +39150,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 225 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { + if (node.kind === 226 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -38903,16 +39272,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -38924,7 +39293,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 /* Any */ | 8192 /* Never */)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -39175,7 +39545,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -39238,7 +39608,7 @@ var ts; checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -39271,6 +39641,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -39342,28 +39713,28 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261 /* SourceFile */: - case 230 /* ModuleDeclaration */: + case 262 /* SourceFile */: + case 231 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 205 /* Block */: + case 233 /* CaseBlock */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; case 150 /* Constructor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: @@ -39387,7 +39758,7 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 228 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_2 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { @@ -39420,9 +39791,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 212 /* ForInStatement */ || - declaration.parent.parent.kind === 213 /* ForOfStatement */)) { + if (declaration.kind === 224 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 213 /* ForInStatement */ || + declaration.parent.parent.kind === 214 /* ForOfStatement */)) { return; } } @@ -39485,7 +39856,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } @@ -39494,7 +39865,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 204 /* Block */) { + if (node.kind === 205 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -39542,6 +39913,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; @@ -39559,6 +39935,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 70 /* Identifier */; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -39570,8 +39962,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70 /* Identifier */; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70 /* Identifier */; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -39588,12 +39980,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39603,12 +39995,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 262 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39643,7 +40035,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 223 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 224 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -39653,17 +40045,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 205 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 225 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 206 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 204 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 231 /* ModuleBlock */ || - container.kind === 230 /* ModuleDeclaration */ || - container.kind === 261 /* SourceFile */); + (container.kind === 205 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 232 /* ModuleBlock */ || + container.kind === 231 /* ModuleDeclaration */ || + container.kind === 262 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -39708,7 +40100,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 /* Parameter */) { + if (symbol.valueDeclaration.kind === 144 /* Parameter */ || + symbol.valueDeclaration.kind === 174 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -39756,7 +40149,7 @@ var ts; } } if (node.kind === 174 /* BindingElement */) { - if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { + if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -39764,13 +40157,13 @@ var ts; checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); + var parent_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); var name_24 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -39785,7 +40178,7 @@ var ts; // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39796,7 +40189,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 213 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39819,18 +40212,19 @@ var ts; if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { + if (node.kind === 224 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 /* Parameter */ && right.kind === 223 /* VariableDeclaration */) || - (left.kind === 223 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { + if ((left.kind === 144 /* Parameter */ && right.kind === 224 /* VariableDeclaration */) || + (left.kind === 224 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -39881,7 +40275,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206 /* EmptyStatement */) { + if (node.thenStatement.kind === 207 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -39901,12 +40295,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 225 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -39929,7 +40323,7 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { @@ -39968,7 +40362,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 225 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -40318,7 +40712,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 254 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 255 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -40330,7 +40724,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 254 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable @@ -40361,7 +40755,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 220 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -40501,7 +40895,7 @@ var ts; /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { @@ -40522,7 +40916,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ || declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 227 /* ClassDeclaration */ || declaration.kind === 228 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -40555,6 +40949,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -40590,7 +40985,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 227 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -40751,7 +41146,7 @@ var ts; // TypeScript 1.0 spec (April 2014): // When a generic interface has multiple declarations, all declarations must have identical type parameter // lists, i.e. identical type parameter names with identical constraints in identical order. - for (var i = 0, len = list1.length; i < len; i++) { + for (var i = 0; i < list1.length; i++) { var tp1 = list1[i]; var tp2 = list2[i]; if (tp1.name.text !== tp2.name.text) { @@ -40811,7 +41206,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 228 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -40953,6 +41348,7 @@ var ts; } return undefined; case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(e); return +e.text; case 183 /* ParenthesizedExpression */: return evalConstant(e.expression); @@ -41033,6 +41429,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -41061,7 +41458,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 229 /* EnumDeclaration */) { + if (declaration.kind !== 230 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -41084,8 +41481,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 226 /* ClassDeclaration */ || - (declaration.kind === 225 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 227 /* ClassDeclaration */ || + (declaration.kind === 226 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -41149,7 +41546,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 226 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 227 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -41200,23 +41597,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 241 /* ExportAssignment */: + case 242 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: var name_25 = node.name; if (ts.isBindingPattern(name_25)) { for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { @@ -41227,12 +41624,12 @@ var ts; break; } // fallthrough - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 225 /* FunctionDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 226 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 229 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -41273,9 +41670,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 242 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -41308,7 +41705,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 /* ExportSpecifier */ ? + var message = node.kind === 244 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -41336,7 +41733,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -41393,8 +41790,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 232 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 262 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -41408,7 +41805,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 /* SourceFile */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 230 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 262 /* SourceFile */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 231 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -41434,9 +41831,14 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 261 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 230 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 262 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 231 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } // Grammar checking @@ -41510,7 +41912,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || + return (declaration.kind !== 226 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || !!declaration.body; } } @@ -41523,10 +41925,10 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -41575,71 +41977,71 @@ var ts; return checkIndexedAccessType(node); case 170 /* MappedType */: return checkMappedType(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return checkBlock(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return checkVariableStatement(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return checkExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return checkIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return checkDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return checkWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return checkForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return checkForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return checkForOfStatement(node); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 215 /* ContinueStatement */: + case 216 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return checkReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return checkWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return checkSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return checkLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return checkThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return checkTryStatement(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return checkVariableDeclaration(node); case 174 /* BindingElement */: return checkBindingElement(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return checkClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return checkImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return checkExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return checkExportAssignment(node); - case 206 /* EmptyStatement */: + case 207 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -41696,6 +42098,7 @@ var ts; // Grammar checking checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -41715,6 +42118,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1 /* TypeChecked */; } } @@ -41772,7 +42179,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 218 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -41795,14 +42202,14 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; case 197 /* ClassExpression */: @@ -41812,8 +42219,8 @@ var ts; } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -41872,10 +42279,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 143 /* TypeParameter */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: return true; } } @@ -41885,7 +42292,7 @@ var ts; while (node.parent && node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 272 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 273 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; @@ -41912,10 +42319,10 @@ var ts; while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 235 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 241 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -41939,13 +42346,13 @@ var ts; default: } } - if (entityName.parent.kind === 240 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 241 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } if (entityName.kind !== 177 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 234 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 235 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -41995,10 +42402,10 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 272 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 273 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 250 /* JsxAttribute */) { + else if (entityName.parent.kind === 251 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 156 /* TypePredicate */) { @@ -42008,7 +42415,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -42066,7 +42473,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 /* ImportDeclaration */ || node.parent.kind === 241 /* ExportDeclaration */) && + ((node.parent.kind === 236 /* ImportDeclaration */ || node.parent.kind === 242 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -42093,7 +42500,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 258 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 259 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -42159,7 +42566,7 @@ var ts; // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 213 /* ForOfStatement */) { + if (expr.parent.kind === 214 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -42171,7 +42578,7 @@ var ts; } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 257 /* PropertyAssignment */) { + if (expr.parent.kind === 258 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } @@ -42312,7 +42719,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 261 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 262 /* SourceFile */) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -42369,7 +42776,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 204 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 205 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -42415,16 +42822,16 @@ var ts; return true; } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -42434,7 +42841,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 262 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -42500,7 +42907,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260 /* EnumMember */) { + if (node.kind === 261 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -42601,9 +43008,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -42732,15 +43139,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 262 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -42760,7 +43167,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 262 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -42946,7 +43353,7 @@ var ts; } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 229 /* EnumDeclaration */ && node.parent.kind === 226 /* ClassDeclaration */) { + if (node.kind !== 230 /* EnumDeclaration */ && node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -42972,7 +43379,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -42995,7 +43402,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 144 /* Parameter */) { @@ -43031,7 +43438,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 144 /* Parameter */) { @@ -43046,13 +43453,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 232 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -43062,14 +43469,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226 /* ClassDeclaration */) { + if (node.kind !== 227 /* ClassDeclaration */) { if (node.kind !== 149 /* MethodDeclaration */ && node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 151 /* GetAccessor */ && node.kind !== 152 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 227 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -43111,7 +43518,7 @@ var ts; } return; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 236 /* ImportDeclaration */ || node.kind === 235 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -43145,29 +43552,29 @@ var ts; case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 155 /* IndexSignature */: - case 230 /* ModuleDeclaration */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: + case 231 /* ModuleDeclaration */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: + case 241 /* ExportAssignment */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 144 /* Parameter */: return false; default: - if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { return false; } switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 227 /* InterfaceDeclaration */: - case 205 /* VariableStatement */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 206 /* VariableStatement */: + case 229 /* TypeAliasDeclaration */: return true; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -43181,7 +43588,7 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 149 /* MethodDeclaration */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: if (!node.asteriskToken) { @@ -43392,7 +43799,7 @@ var ts; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 /* FunctionDeclaration */ || + ts.Debug.assert(node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || node.kind === 149 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { @@ -43419,7 +43826,7 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */) { + if (prop.kind === 260 /* SpreadAssignment */) { continue; } var name_28 = prop.name; @@ -43427,7 +43834,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_28); } - if (prop.kind === 258 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 259 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -43450,7 +43857,7 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */) { + if (prop.kind === 258 /* PropertyAssignment */ || prop.kind === 259 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_28.kind === 8 /* NumericLiteral */) { @@ -43500,7 +43907,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251 /* JsxSpreadAttribute */) { + if (attr.kind === 252 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -43512,7 +43919,7 @@ var ts; return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 253 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -43521,7 +43928,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -43536,20 +43943,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 213 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -43642,7 +44049,7 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 228 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } else if (node.parent.kind === 161 /* TypeLiteral */) { @@ -43656,11 +44063,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 214 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 215 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -43668,8 +44075,8 @@ var ts; return false; } break; - case 218 /* SwitchStatement */: - if (node.kind === 215 /* BreakStatement */ && !node.label) { + case 219 /* SwitchStatement */: + if (node.kind === 216 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -43684,13 +44091,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 /* BreakStatement */ + var message = node.kind === 216 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 215 /* BreakStatement */ + var message = node.kind === 216 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -43717,7 +44124,7 @@ var ts; expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 /* ForInStatement */ && node.parent.parent.kind !== 213 /* ForOfStatement */) { + if (node.parent.parent.kind !== 213 /* ForInStatement */ && node.parent.parent.kind !== 214 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -43782,15 +44189,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 209 /* IfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: return false; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -43805,6 +44212,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -43845,7 +44259,7 @@ var ts; return true; } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 228 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -43878,13 +44292,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 227 /* InterfaceDeclaration */ || - node.kind === 228 /* TypeAliasDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 241 /* ExportDeclaration */ || - node.kind === 240 /* ExportAssignment */ || - node.kind === 233 /* NamespaceExportDeclaration */ || + if (node.kind === 228 /* InterfaceDeclaration */ || + node.kind === 229 /* TypeAliasDeclaration */ || + node.kind === 236 /* ImportDeclaration */ || + node.kind === 235 /* ImportEqualsDeclaration */ || + node.kind === 242 /* ExportDeclaration */ || + node.kind === 241 /* ExportAssignment */ || + node.kind === 234 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -43893,7 +44307,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 205 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 206 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -43919,7 +44333,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 204 /* Block */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 205 /* Block */ || node.parent.kind === 232 /* ModuleBlock */ || node.parent.kind === 262 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -43932,8 +44346,22 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.isOctalLiteral && languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1 /* ES5 */) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 171 /* LiteralType */)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 261 /* EnumMember */)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37 /* MinusToken */; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -43997,31 +44425,31 @@ var ts; _a[201 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[229 /* EnumDeclaration */] = [ + _a[230 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[230 /* ModuleDeclaration */] = [ + _a[231 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[231 /* ModuleBlock */] = [ + _a[232 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[234 /* ImportEqualsDeclaration */] = [ + _a[235 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[245 /* ExternalModuleReference */] = [ + _a[246 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[260 /* EnumMember */] = [ + _a[261 /* EnumMember */] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -44059,11 +44487,11 @@ var ts; var result = initial; switch (node.kind) { // Leaf nodes - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: + case 204 /* SemicolonClassElement */: + case 207 /* EmptyStatement */: case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: - case 293 /* NotEmittedStatement */: + case 223 /* DebuggerStatement */: + case 294 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -44211,73 +44639,73 @@ var ts; result = reduceNodes(node.typeArguments, cbNodes, result); break; // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 204 /* Block */: + case 205 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 208 /* IfStatement */: + case 209 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209 /* DoStatement */: + case 210 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 210 /* WhileStatement */: - case 217 /* WithStatement */: + case 211 /* WhileStatement */: + case 218 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 211 /* ForStatement */: + case 212 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 217 /* ReturnStatement */: + case 221 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221 /* TryStatement */: + case 222 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44286,7 +44714,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44294,97 +44722,97 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236 /* ImportClause */: + case 237 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 249 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.attributes, cbNodes, result); break; - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // fall-through - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 256 /* CatchClause */: + case 257 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; default: @@ -44542,10 +44970,10 @@ var ts; return node; } switch (node.kind) { - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: + case 204 /* SemicolonClassElement */: + case 207 /* EmptyStatement */: case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names @@ -44620,107 +45048,107 @@ var ts; case 199 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 204 /* Block */: + case 205 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 238 /* NamedImports */: + case 239 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 242 /* NamedExports */: + case 243 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -44836,7 +45264,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 199 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -45412,15 +45840,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 231 /* ModuleBlock */: - case 204 /* Block */: + case 262 /* SourceFile */: + case 233 /* CaseBlock */: + case 232 /* ModuleBlock */: + case 205 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226 /* ClassDeclaration */: - case 225 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: + case 226 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -45467,13 +45895,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -45493,11 +45921,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 241 /* ExportDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 236 /* ImportClause */ || - (node.kind === 234 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 245 /* ExternalModuleReference */)) { + if (node.kind === 242 /* ExportDeclaration */ || + node.kind === 236 /* ImportDeclaration */ || + node.kind === 237 /* ImportClause */ || + (node.kind === 235 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 246 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -45539,7 +45967,7 @@ var ts; case 149 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -45608,18 +46036,18 @@ var ts; // TypeScript index signatures are elided. case 145 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. case 147 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; case 150 /* Constructor */: return visitConstructor(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -45641,7 +46069,7 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: @@ -45660,7 +46088,7 @@ var ts; case 152 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: @@ -45694,18 +46122,18 @@ var ts; case 201 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -46113,7 +46541,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -46622,7 +47050,7 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 149 /* MethodDeclaration */: @@ -46645,7 +47073,7 @@ var ts; return serializeTypeNode(node.type); case 152 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: case 149 /* MethodDeclaration */: return ts.createIdentifier("Function"); @@ -46730,6 +47158,9 @@ var ts; } switch (node.kind) { case 104 /* VoidKeyword */: + case 137 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 129 /* NeverKeyword */: return ts.createVoidZero(); case 166 /* ParenthesizedType */: return serializeTypeNode(node.type); @@ -46768,34 +47199,7 @@ var ts; return serializeTypeReferenceNode(node); case 165 /* IntersectionType */: case 164 /* UnionType */: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - // Non identifier - if (serializedIndividual.kind !== 70 /* Identifier */) { - serializedUnion = undefined; - break; - } - // One of the individual is global object, return immediately - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - // Different types - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - // If we were able to find common type - if (serializedUnion) { - return serializedUnion; - } - } - // Fallthrough + return serializeUnionOrIntersectionType(node); case 160 /* TypeQuery */: case 168 /* TypeOperator */: case 169 /* IndexedAccessType */: @@ -46810,6 +47214,37 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + // If we dont have any other type already set, set the initial type + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + // One of the individual is global object, return immediately + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + // Different types + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + // Initialize the union type + serializedUnion = serializedIndividual; + } + } + // If we were able to find common type, use it + return serializedUnion; + } /** * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with * decorator type metadata. @@ -47411,7 +47846,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 229 /* EnumDeclaration */) { + if (node.kind === 230 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -47530,8 +47965,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231 /* ModuleBlock */) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 232 /* ModuleBlock */) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -47576,13 +48011,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 231 /* ModuleBlock */) { + if (body.kind !== 232 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -47623,7 +48058,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 237 /* NamespaceImport */) { + if (node.kind === 238 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -47855,16 +48290,16 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); + context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(230 /* ModuleDeclaration */); + context.enableEmitNotification(231 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 231 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 230 /* EnumDeclaration */; } /** * Hook for node emit. @@ -47960,9 +48395,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 261 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 230 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 229 /* EnumDeclaration */); + if (container && container.kind !== 262 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 231 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 230 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -48082,11 +48517,11 @@ var ts; return visitObjectLiteralExpression(node); case 192 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitForOfStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); case 188 /* VoidExpression */: return visitVoidExpression(node); @@ -48098,7 +48533,7 @@ var ts; return visitGetAccessorDeclaration(node); case 152 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); @@ -48106,7 +48541,7 @@ var ts; return visitArrowFunction(node); case 144 /* Parameter */: return visitParameter(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return visitExpressionStatement(node); case 183 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); @@ -48119,7 +48554,7 @@ var ts; var objects = []; for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { var e = elements_3[_i]; - if (e.kind === 259 /* SpreadAssignment */) { + if (e.kind === 260 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -48131,7 +48566,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257 /* PropertyAssignment */) { + if (e.kind === 258 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -48361,11 +48796,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48375,11 +48810,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return visitJsxExpression(node); - case 246 /* JsxElement */: + case 247 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -48440,7 +48875,10 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; } - else if (node.kind === 252 /* JsxExpression */) { + else if (node.kind === 253 /* JsxExpression */) { + if (node.expression === undefined) { + return ts.createLiteral(true); + } return visitJsxExpression(node); } else { @@ -48522,7 +48960,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246 /* JsxElement */) { + if (node.kind === 247 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -48868,7 +49306,7 @@ var ts; case 149 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: @@ -49032,7 +49470,7 @@ var ts; context.enableSubstitution(177 /* PropertyAccessExpression */); context.enableSubstitution(178 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(226 /* ClassDeclaration */); + context.enableEmitNotification(227 /* ClassDeclaration */); context.enableEmitNotification(149 /* MethodDeclaration */); context.enableEmitNotification(151 /* GetAccessor */); context.enableEmitNotification(152 /* SetAccessor */); @@ -49089,7 +49527,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 /* ClassDeclaration */ + return kind === 227 /* ClassDeclaration */ || kind === 150 /* Constructor */ || kind === 149 /* MethodDeclaration */ || kind === 151 /* GetAccessor */ @@ -49299,6 +49737,82 @@ var ts; */ SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; })(SuperCaptureResult || (SuperCaptureResult = {})); + // Facts we track as we traverse the tree + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + // + // Ancestor facts + // + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + // + // Ancestor masks + // + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + // We are always in *some* kind of block scope, but only specific block-scope containers are + // top-level or Blocks. + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + // A source file is a top-level block scope. + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + // Functions, methods, and accessors are both new lexical scopes and new block scopes. + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + // Arrow functions are lexically scoped to their container, but are new block scopes. + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + // Constructors are both new lexical scopes and new block scopes. Constructors are also + // always considered non-static members of a class. + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + // 'do' and 'while' statements are not block scopes. We track that the subtree is contained + // within an IterationStatement to indicate whether the embedded statement is an + // IterationStatementBlock. + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + // 'for' statements are new block scopes and have special handling for 'let' declarations. + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + // 'for-in' and 'for-of' statements are new block scopes and have special handling for + // 'let' declarations. + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + // Blocks (other than function bodies) are new block scopes. + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + // Computed property names track subtree flags differently than their containing members. + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + // + // Subtree facts + // + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + // + // Subtree masks + // + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -49308,15 +49822,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; /** * Used to track if we are emitting body of the converted loop */ @@ -49334,185 +49840,116 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0 /* None */; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + **/ + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072 /* AsyncFunctionBody */)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case 205 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 224 /* VariableDeclarationList */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree, propagating specific facts from the subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. + * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. + **/ + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 /* ReturnStatement */ && !node.expression; + return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ + && node.kind === 217 /* ReturnStatement */ + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES2015 */) !== 0 || - node.kind === 219 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && ts.isStatement(node)) + || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - // we want to dive in this branch either if node has children with ES2015 specific syntax - // or we are inside constructor that captures result of the super call so all returns without expression should be - // rewritten. Note: we skip expressions since returns should never appear there - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, /*isFunctionBody*/ true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216 /* ReturnStatement */: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205 /* VariableStatement */: - return visitVariableStatement(node); - case 218 /* SwitchStatement */: - return visitSwitchStatement(node); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 98 /* ThisKeyword */: - return visitThisKeyword(node); - case 70 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96 /* SuperKeyword */) { + return visitSuperKeyword(/*isExpressionOfCall*/ true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114 /* StaticKeyword */: return undefined; // elide static keyword - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); case 197 /* ClassExpression */: return visitClassExpression(node); case 144 /* Parameter */: return visitParameter(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 185 /* ArrowFunction */: return visitArrowFunction(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 219 /* LabeledStatement */: + case 219 /* SwitchStatement */: + return visitSwitchStatement(node); + case 233 /* CaseBlock */: + return visitCaseBlock(node); + case 205 /* Block */: + return visitBlock(node, /*isFunctionBody*/ false); + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 220 /* LabeledStatement */: return visitLabeledStatement(node); - case 209 /* DoStatement */: - return visitDoStatement(node); - case 210 /* WhileStatement */: - return visitWhileStatement(node); - case 211 /* ForStatement */: - return visitForStatement(node); - case 212 /* ForInStatement */: - return visitForInStatement(node); - case 213 /* ForOfStatement */: - return visitForOfStatement(node); - case 207 /* ExpressionStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); + case 212 /* ForStatement */: + return visitForStatement(node, /*outermostLabeledStatement*/ undefined); + case 213 /* ForInStatement */: + return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); + case 214 /* ForOfStatement */: + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); + case 208 /* ExpressionStatement */: return visitExpressionStatement(node); case 176 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitCatchClause(node); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); + case 142 /* ComputedPropertyName */: + return visitComputedPropertyName(node); case 175 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); case 179 /* CallExpression */: @@ -49537,54 +49974,82 @@ var ts; case 196 /* SpreadElement */: return visitSpreadElement(node); case 96 /* SuperKeyword */: - return visitSuperKeyword(); - case 195 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); + return visitSuperKeyword(/*isExpressionOfCall*/ false); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 202 /* MetaProperty */: + return visitMetaProperty(node); case 149 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 205 /* VariableStatement */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return visitAccessorDeclaration(node); + case 206 /* VariableStatement */: return visitVariableStatement(node); + case 217 /* ReturnStatement */: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8 /* Return */; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8 /* Return */; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -49604,13 +50069,13 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 215 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 216 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 216 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -49621,7 +50086,7 @@ var ts; } } else { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 216 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -49813,6 +50278,9 @@ var ts; * @param extendsClauseElement The expression for the class `extends` clause. */ function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration( @@ -49826,6 +50294,8 @@ var ts; ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; } /** * Transforms the parameters of the constructor declaration of a class. @@ -49871,26 +50341,31 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // determine whether the class is known syntactically to be a derived class (e.g. a + // class that extends a value that is not syntactically known to be `null`). + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94 /* NullKeyword */; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1 /* ReplaceSuperCapture */; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1 /* ReplaceSuperCapture */) { + hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset)); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 /* ReplaceWithReturn */ && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); + } var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ constructor ? constructor.body.statements : node.members), /*location*/ constructor ? constructor.body : node, @@ -49907,17 +50382,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 216 /* ReturnStatement */) { + if (statement.kind === 217 /* ReturnStatement */) { return true; } - else if (statement.kind === 208 /* IfStatement */) { + else if (statement.kind === 209 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204 /* Block */) { + else if (statement.kind === 205 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -49930,9 +50405,9 @@ var ts; * * @returns The new statement offset into the `statements` array. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -49975,9 +50450,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } // Return the result if we have an immediate super() call on the last statement, @@ -49996,18 +50470,18 @@ var ts; return 2 /* ReplaceWithReturn */; } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { return 1 /* ReplaceSuperCapture */; } return 0 /* NoReplacement */; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -50202,6 +50676,46 @@ var ts; ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384 /* NewTarget */) { + var newTarget = void 0; + switch (node.kind) { + case 185 /* ArrowFunction */: + return statements; + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + // Methods and accessors cannot be constructors, so 'new.target' will + // always return 'undefined'. + newTarget = ts.createVoidZero(); + break; + case 150 /* Constructor */: + // Class constructors can only be called with `new`, so `this.constructor` + // should be relatively safe to use. + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); + break; + case 226 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + // Functions can be called or constructed, and may have a `this` due to + // being a member or when calling an imported function via `other_1.f()`. + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", + /*type*/ undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -50213,17 +50727,17 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 149 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 151 /* GetAccessor */: case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; case 150 /* Constructor */: @@ -50249,11 +50763,12 @@ var ts; * @param receiver The receiver for the member. * @param member The MethodDeclaration node. */ - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), @@ -50264,6 +50779,7 @@ var ts; // No source map should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 48 /* NoSourceMap */); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return statement; } /** @@ -50272,8 +50788,8 @@ var ts; * @param receiver The receiver for the member. * @param accessors The set of related get/set accessors. */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false), /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the @@ -50287,8 +50803,9 @@ var ts; * * @param receiver The receiver for the member. */ - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); @@ -50299,7 +50816,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -50307,7 +50824,7 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -50324,6 +50841,7 @@ var ts; if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return call; } /** @@ -50335,6 +50853,9 @@ var ts; if (node.transformFlags & 16384 /* ContainsLexicalThis */) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); var func = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -50343,6 +50864,8 @@ var ts; /*type*/ undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; return func; } /** @@ -50351,12 +50874,24 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var ancestorFacts = ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */ + ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Visits a FunctionDeclaration node. @@ -50364,12 +50899,22 @@ var ts; * @param node a FunctionDeclaration node. */ function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, node.modifiers, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Transforms a function-like node into a FunctionExpression. @@ -50378,18 +50923,24 @@ var ts; * @param location The source-map location for the new FunctionExpression. * @param name The name of the new FunctionExpression. */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */) + ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 226 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression( + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body, location), /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** * Transforms the body of a function-like node. @@ -50451,6 +51002,7 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; @@ -50465,6 +51017,23 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true), + /*location*/ updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + // A function body is not a block scope. + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ + ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) + : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -50511,9 +51080,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { + var ancestorFacts = enterSubtree(0 /* None */, ts.hasModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -50531,14 +51103,18 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + updated = ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); } else { // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } /** * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). @@ -50546,25 +51122,28 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64 /* ES2015 */) { + if (node.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } /** * Gets a value indicating whether we should emit an explicit initializer for a variable @@ -50615,18 +51194,16 @@ var ts; var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 213 /* ForOfStatement */ + && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -50655,55 +51232,52 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. + var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, + /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels[node.label.text] = node.label.text; + } + function resetLabel(node) { + convertedLoopState.labels[node.label.text] = undefined; + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: // // for (let v of expr) { } @@ -50815,7 +51389,20 @@ var ts; /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); - return forStatement; + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 212 /* ForStatement */: + return visitForStatement(node, outermostLabeledStatement); + case 213 /* ForInStatement */: + return visitForInStatement(node, outermostLabeledStatement); + case 214 /* ForOfStatement */: + return visitForOfStatement(node, outermostLabeledStatement); + } } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -50829,31 +51416,40 @@ var ts; // Find the first computed property. // Everything until that point can be emitted as part of the initial object literal. var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 /* ContainsYield */ - || property.name.kind === 142 /* ComputedPropertyName */) { + if ((property.transformFlags & 16777216 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 142 /* ComputedPropertyName */) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 32768 /* Indented */)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), + /*location*/ undefined, node.multiLine), 32768 /* Indented */)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; @@ -50880,7 +51476,7 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { @@ -50889,7 +51485,9 @@ var ts; saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -50898,11 +51496,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 225 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -50939,7 +51537,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -50951,11 +51549,13 @@ var ts; ts.addRange(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, /*location*/ undefined, /*multiline*/ true); } - if (!ts.isBlock(loopBody)) { + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; + } + else { loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072 /* AsyncFunctionBody */) !== 0 + var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -51038,25 +51638,24 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); + var clone_4 = ts.getMutableClone(node); // clean statement part - loop.statement = undefined; + clone_4.statement = undefined; // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); + clone_4 = ts.visitEachChild(clone_4, visitor, context); // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, /*location*/ undefined, /*multiline*/ true); // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -51186,18 +51785,18 @@ var ts; case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257 /* PropertyAssignment */: + case 149 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 258 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -51241,22 +51840,32 @@ var ts; * @param method The MethodDeclaration node. * @param receiver The receiver for the assignment. */ - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container), /*location*/ method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); - var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -51273,11 +51882,26 @@ var ts; // Methods on classes are handled in visitClassDeclaration/visitClassExpression. // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); + var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, /*location*/ node); } + /** + * Visits an AccessorDeclaration of an ObjectLiteralExpression. + * + * @param node An AccessorDeclaration node. + */ + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return updated; + } /** * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. * @@ -51287,6 +51911,12 @@ var ts; return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), /*location*/ node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0 /* ComputedPropertyNameExcludes */, 8192 /* ComputedPropertyNameIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 32768 /* NewTargetInComputedPropertyName */ : 0 /* None */); + return updated; + } /** * Visits a YieldExpression node. * @@ -51302,8 +51932,11 @@ var ts; * @param node An ArrayLiteralExpression node. */ function visitArrayLiteralExpression(node) { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + if (node.transformFlags & 64 /* ES2015 */) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } /** * Visits a CallExpression that contains either a spread element or `super`. @@ -51311,7 +51944,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + if (node.transformFlags & 64 /* ES2015 */) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); @@ -51338,7 +51975,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -51350,18 +51987,18 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } if (node.expression.kind === 96 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } /** * Visits a NewExpression that contains a spread element. @@ -51369,16 +52006,18 @@ var ts; * @param node A NewExpression node. */ function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 524288 /* ContainsSpread */) !== 0); - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), - /*typeArguments*/ undefined, []); + if (node.transformFlags & 524288 /* ContainsSpread */) { + // We are here because we contain a SpreadElementExpression. + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + /*typeArguments*/ undefined, []); + } + return ts.visitEachChild(node, visitor, context); } /** * Transforms an array of Expression nodes that contains a SpreadExpression. @@ -51581,27 +52220,40 @@ var ts; /** * Visits the `super` keyword */ - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 179 /* CallExpression */ + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 /* NonStaticClassElement */ + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target") { + if (hierarchyFacts & 8192 /* ComputedPropertyName */) { + hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; + } + else { + hierarchyFacts |= 16384 /* NewTarget */; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } /** * Called by the printer just before a node is printed. * * @param node The node to be printed. */ function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ + ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ + : 65 /* FunctionIncludes */); + previousOnEmitNode(emitContext, node, emitCallback); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return; } previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; } /** * Enables a more costly code path for substitutions when we determine a source file @@ -51627,7 +52279,7 @@ var ts; context.enableEmitNotification(152 /* SetAccessor */); context.enableEmitNotification(185 /* ArrowFunction */); context.enableEmitNotification(184 /* FunctionExpression */); - context.enableEmitNotification(225 /* FunctionDeclaration */); + context.enableEmitNotification(226 /* FunctionDeclaration */); } } /** @@ -51670,9 +52322,9 @@ var ts; var parent = node.parent; switch (parent.kind) { case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 223 /* VariableDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 224 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -51713,8 +52365,7 @@ var ts; */ function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8 /* CapturesThis */) { + && hierarchyFacts & 16 /* CapturesThis */) { return ts.createIdentifier("_this", /*location*/ node); } return node; @@ -51731,7 +52382,7 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 208 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; @@ -51763,7 +52414,7 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); /// @@ -52036,13 +52687,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitWhileStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -52055,24 +52706,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); case 151 /* GetAccessor */: case 152 /* SetAccessor */: return visitAccessorDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitForInStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return visitBreakStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return visitContinueStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -52120,7 +52771,7 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); case 184 /* FunctionExpression */: return visitFunctionExpression(node); @@ -52405,10 +53056,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -52553,7 +53204,7 @@ var ts; emitYield(expression, /*location*/ node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(/*location*/ node); } /** * Visits an ArrayLiteralExpression that contains a YieldExpression. @@ -52667,10 +53318,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -52737,35 +53388,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204 /* Block */: + case 205 /* Block */: return transformAndEmitBlock(node); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return transformAndEmitIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return transformAndEmitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return transformAndEmitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return transformAndEmitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -52785,7 +53436,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name_37 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_37, variable.name); + hoistVariableDeclaration(name_37); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -52828,7 +53481,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -53185,7 +53838,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 255 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -53198,7 +53851,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 254 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -53359,12 +54012,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_38) { + var clone_7 = ts.getMutableClone(name_38); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -54249,9 +54902,9 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation)); + : [createInstruction(2 /* Return */)]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -54261,10 +54914,10 @@ var ts; */ function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation)); + ]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -54274,10 +54927,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -54287,10 +54940,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -54300,9 +54953,9 @@ var ts; */ function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation)); + : [createInstruction(4 /* Yield */)]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -54312,10 +54965,10 @@ var ts; */ function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createReturn(ts.createArrayLiteral([ createInstruction(5 /* YieldStar */), expression - ]), operationLocation)); + ]), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -54411,10 +55064,22 @@ var ts; * @param context Context and state information for the transformation. */ function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + // enable emit notification only if using --jsx preserve + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 /* Preserve */) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(249 /* JsxOpeningElement */); + context.enableEmitNotification(250 /* JsxClosingElement */); + context.enableEmitNotification(248 /* JsxSelfClosingElement */); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(257 /* PropertyAssignment */); + context.enableSubstitution(258 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -54424,6 +55089,22 @@ var ts; function transformSourceFile(node) { return node; } + /** + * Called by the printer just before a node is printed. + * + * @param node The node to be printed. + */ + function onEmitNode(emitContext, node, emitCallback) { + switch (node.kind) { + case 249 /* JsxOpeningElement */: + case 250 /* JsxClosingElement */: + case 248 /* JsxSelfClosingElement */: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(emitContext, node, emitCallback); + } /** * Hooks node substitutions. * @@ -54431,6 +55112,9 @@ var ts; * @param node The node to substitute. */ function onSubstituteNode(emitContext, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(emitContext, node); + } node = previousOnSubstituteNode(emitContext, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); @@ -54490,7 +55174,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261 /* SourceFile */); + context.enableEmitNotification(262 /* SourceFile */); context.enableSubstitution(70 /* Identifier */); var currentSourceFile; return transformSourceFile; @@ -54517,10 +55201,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -54595,7 +55279,7 @@ var ts; context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. @@ -54815,7 +55499,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 242 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -54840,7 +55524,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241 /* ExportDeclaration */) { + if (externalImport.kind !== 242 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -54921,19 +55605,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -54983,15 +55667,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -55169,7 +55853,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 261 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 262 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -55233,7 +55917,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -55289,10 +55973,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 239 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -55471,43 +56155,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return visitForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return visitForOfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return visitWhileStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return visitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return visitSwitchStatement(node); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return visitCaseBlock(node); - case 253 /* CaseClause */: + case 254 /* CaseClause */: return visitCaseClause(node); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return visitDefaultClause(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return visitTryStatement(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return visitCatchClause(node); - case 204 /* Block */: + case 205 /* Block */: return visitBlock(node); - case 295 /* MergeDeclarationMarker */: + case 296 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 297 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -55735,7 +56419,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261 /* SourceFile */; + return container !== undefined && container.kind === 262 /* SourceFile */; } else { return false; @@ -55768,7 +56452,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -55941,7 +56625,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -55997,8 +56681,8 @@ var ts; context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(259 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(262 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -56052,26 +56736,6 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { // An AMD define function has the following shape: // // define(id?, dependencies?, factory); @@ -56092,7 +56756,7 @@ var ts; // /// // // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; // Create an updated SourceFile: // // define(moduleName?, ["module1", "module2"], function ... @@ -56122,6 +56786,73 @@ var ts; ], /*location*/ node.statements)); } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, [ + ts.createVariableDeclaration("v", + /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], + /*location*/ undefined, + /*multiLine*/ true)); + // Create an updated SourceFile: + // + // (function (factory) { + // if (typeof module === "object" && typeof module.exports === "object") { + // var v = factory(require, exports); + // if (v !== undefined) module.exports = v; + // } + // else if (typeof define === 'function' && define.amd) { + // define(["require", "exports"], factory); + // } + // })(function ...) + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, + /*typeArguments*/ undefined, [ + // Add the module body function argument: + // + // function (require, exports) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ])) + ], + /*location*/ node.statements)); + } /** * Collect the additional asynchronous dependencies for the module. * @@ -56226,23 +56957,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return visitExportDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return visitExportAssignment(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return visitClassDeclaration(node); - case 295 /* MergeDeclarationMarker */: + case 296 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 297 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: // This visitor does not descend into the tree, as export/import statements @@ -56554,7 +57285,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 206 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -56609,10 +57340,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 239 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -56811,7 +57542,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 262 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = ts.createMap(); @@ -56899,7 +57630,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 262 /* SourceFile */) { return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), /*location*/ node); } @@ -56910,8 +57641,8 @@ var ts; /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), + var name_39 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), /*location*/ node); } } @@ -57013,8 +57744,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - // emit output for the UMD helper function. - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); /// /// @@ -57521,7 +58250,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 294 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -57534,7 +58263,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 294 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -57713,7 +58442,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 294 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -57732,7 +58461,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 225 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -58045,7 +58774,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 236 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -58120,10 +58849,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223 /* VariableDeclaration */) { + if (declaration.kind === 224 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 /* NamedImports */ || declaration.kind === 239 /* ImportSpecifier */ || declaration.kind === 236 /* ImportClause */) { + else if (declaration.kind === 239 /* NamedImports */ || declaration.kind === 240 /* ImportSpecifier */ || declaration.kind === 237 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -58141,7 +58870,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 236 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -58151,12 +58880,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 231 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -58334,7 +59063,7 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 234 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 235 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); @@ -58456,9 +59185,9 @@ var ts; var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } @@ -58505,10 +59234,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 /* ImportEqualsDeclaration */ || - (node.parent.kind === 261 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 235 /* ImportEqualsDeclaration */ || + (node.parent.kind === 262 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 262 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -58518,7 +59247,7 @@ var ts; }); } else { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -58536,23 +59265,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return writeVariableStatement(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return writeClassDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -58560,7 +59289,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 262 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -58569,7 +59298,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 227 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 228 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -58621,7 +59350,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 238 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -58645,7 +59374,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 238 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -58666,13 +59395,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 231 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 234 /* ImportEqualsDeclaration */) { + if (parent.kind === 235 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230 /* ModuleDeclaration */) { + else if (parent.kind === 231 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -58742,7 +59471,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231 /* ModuleBlock */) { + while (node.body && node.body.kind !== 232 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -58842,10 +59571,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 154 /* ConstructSignature */: @@ -58859,17 +59588,17 @@ var ts; if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 227 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -58907,7 +59636,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + if (node.parent.parent.kind === 227 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -58994,7 +59723,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 223 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 224 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -59022,7 +59751,7 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 224 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59038,7 +59767,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59212,13 +59941,13 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 226 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 226 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } @@ -59323,7 +60052,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 227 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59337,7 +60066,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59420,7 +60149,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 227 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59433,7 +60162,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59509,20 +60238,20 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 227 /* InterfaceDeclaration */: - case 226 /* ClassDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 226 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 228 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return emitExportDeclaration(node); case 150 /* Constructor */: case 149 /* MethodDeclaration */: @@ -59538,11 +60267,11 @@ var ts; case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return emitPropertyDeclaration(node); - case 260 /* EnumMember */: + case 261 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return emitExportAssignment(node); - case 261 /* SourceFile */: + case 262 /* SourceFile */: return emitSourceFile(node); } } @@ -59835,7 +60564,7 @@ var ts; var kind = node.kind; switch (kind) { // Top-level nodes - case 261 /* SourceFile */: + case 262 /* SourceFile */: return emitSourceFile(node); } } @@ -59983,126 +60712,126 @@ var ts; case 174 /* BindingElement */: return emitBindingElement(node); // Misc - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return emitTemplateSpan(node); - case 203 /* SemicolonClassElement */: + case 204 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 204 /* Block */: + case 205 /* Block */: return emitBlock(node); - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: return emitVariableStatement(node); - case 206 /* EmptyStatement */: + case 207 /* EmptyStatement */: return emitEmptyStatement(); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return emitExpressionStatement(node); - case 208 /* IfStatement */: + case 209 /* IfStatement */: return emitIfStatement(node); - case 209 /* DoStatement */: + case 210 /* DoStatement */: return emitDoStatement(node); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: return emitWhileStatement(node); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return emitForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: return emitForInStatement(node); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return emitForOfStatement(node); - case 214 /* ContinueStatement */: + case 215 /* ContinueStatement */: return emitContinueStatement(node); - case 215 /* BreakStatement */: + case 216 /* BreakStatement */: return emitBreakStatement(node); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: return emitReturnStatement(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: return emitWithStatement(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return emitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: return emitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: return emitThrowStatement(node); - case 221 /* TryStatement */: + case 222 /* TryStatement */: return emitTryStatement(node); - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 224 /* VariableDeclarationList */: + case 225 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: return emitClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return emitModuleBlock(node); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return emitCaseBlock(node); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: return emitImportDeclaration(node); - case 236 /* ImportClause */: + case 237 /* ImportClause */: return emitImportClause(node); - case 237 /* NamespaceImport */: + case 238 /* NamespaceImport */: return emitNamespaceImport(node); - case 238 /* NamedImports */: + case 239 /* NamedImports */: return emitNamedImports(node); - case 239 /* ImportSpecifier */: + case 240 /* ImportSpecifier */: return emitImportSpecifier(node); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: return emitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: return emitExportDeclaration(node); - case 242 /* NamedExports */: + case 243 /* NamedExports */: return emitNamedExports(node); - case 243 /* ExportSpecifier */: + case 244 /* ExportSpecifier */: return emitExportSpecifier(node); - case 244 /* MissingDeclaration */: + case 245 /* MissingDeclaration */: return; // Module references - case 245 /* ExternalModuleReference */: + case 246 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: return emitJsxAttribute(node); - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 252 /* JsxExpression */: + case 253 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 253 /* CaseClause */: + case 254 /* CaseClause */: return emitCaseClause(node); - case 254 /* DefaultClause */: + case 255 /* DefaultClause */: return emitDefaultClause(node); - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: return emitHeritageClause(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 257 /* PropertyAssignment */: + case 258 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 258 /* ShorthandPropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 259 /* SpreadAssignment */: + case 260 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 260 /* EnumMember */: + case 261 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -60191,16 +60920,16 @@ var ts; return emitAsExpression(node); case 201 /* NonNullExpression */: return emitNonNullExpression(node); + case 202 /* MetaProperty */: + return emitMetaProperty(node); // JSX - case 246 /* JsxElement */: + case 247 /* JsxElement */: return emitJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 295 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 297 /* RawExpression */: - return writeLines(node.text); } } // @@ -60693,6 +61422,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } // // Misc // @@ -60741,27 +61475,27 @@ var ts; writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 208 /* IfStatement */) { + if (node.elseStatement.kind === 209 /* IfStatement */) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -60771,7 +61505,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60783,7 +61517,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60793,7 +61527,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60803,11 +61537,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 225 /* VariableDeclarationList */) { emit(node); } else { @@ -60834,7 +61568,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); @@ -60858,9 +61592,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -61046,7 +61783,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230 /* ModuleDeclaration */) { + while (body.kind === 231 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -61203,6 +61940,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -61438,8 +62178,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { write(" "); emit(node); } @@ -61580,6 +62320,14 @@ var ts; write(getClosingBracket(format)); } } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1 /* SingleLine */) { + write(" "); + } + else { + writeLine(); + } + } function writeIfAny(nodes, text) { if (nodes && nodes.length > 0) { write(text); @@ -61771,10 +62519,10 @@ var ts; */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_40 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name_41 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_40; + return name_41; } } while (true) { @@ -61782,11 +62530,11 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -61826,6 +62574,12 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameForNodeCached(node.name); + } + return makeTempVariableName(0 /* Auto */); + } /** * Generates a unique name from a node. * @@ -61835,18 +62589,22 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 235 /* ImportDeclaration */: - case 241 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: + case 242 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: - case 240 /* ExportAssignment */: + case 226 /* FunctionDeclaration */: + case 227 /* ClassDeclaration */: + case 241 /* ExportAssignment */: return generateNameForExportDefault(); case 197 /* ClassExpression */: return generateNameForClassExpression(); + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); } @@ -61890,6 +62648,10 @@ var ts; // otherwise, return the original node for the source; return node; } + function generateNameForNodeCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } /** * Gets the generated identifier text from a generated identifier. * @@ -61900,8 +62662,7 @@ var ts; // Generated names generate unique names based on their original node // and are cached based on that node's id var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + return generateNameForNodeCached(node); } else { // Auto, Loop, and Unique names are cached based on their unique @@ -62046,7 +62807,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { // Failed to find any common path component @@ -62237,10 +62999,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name_43 = names_1[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -62276,6 +63038,7 @@ var ts; var supportedExtensions = ts.getSupportedExtensions(options); // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -62289,7 +63052,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -62335,6 +63099,8 @@ var ts; } } } + // unconditionally set moduleResolutionCache to undefined to avoid unnecessary leaks + moduleResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; program = { @@ -62600,7 +63366,7 @@ var ts; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } // update fileName -> file mapping - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -62787,10 +63553,10 @@ var ts; case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 223 /* VariableDeclaration */: + case 226 /* FunctionDeclaration */: + case 224 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -62798,32 +63564,32 @@ var ts; } } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255 /* HeritageClause */: + case 256 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; case 182 /* TypeAssertionExpression */: @@ -62841,26 +63607,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // pass through - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 206 /* VariableStatement */); } break; case 147 /* PropertyDeclaration */: @@ -62983,7 +63749,7 @@ var ts; // synthesize 'import "tslib"' declaration var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235 /* ImportDeclaration */); + var importDecl = ts.createSynthesizedNode(236 /* ImportDeclaration */); importDecl.parent = file; externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; @@ -63001,9 +63767,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 242 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -63018,7 +63784,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -64281,11 +65047,11 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_43) { + switch (name_44) { case "init": case "watch": case "version": @@ -64293,14 +65059,14 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_43] = value; + result[name_44] = value; } else { if (optionDefinition.type === "list") { @@ -64309,11 +65075,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name_44] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -64361,6 +65127,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -65130,32 +65897,32 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 144 /* Parameter */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: - case 260 /* EnumMember */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: + case 261 /* EnumMember */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 256 /* CatchClause */: + case 257 /* CatchClause */: return 1 /* Value */; case 143 /* TypeParameter */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: case 161 /* TypeLiteral */: return 2 /* Type */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -65165,22 +65932,22 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* NamedImports */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 239 /* NamedImports */: + case 240 /* ImportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 236 /* ImportDeclaration */: + case 241 /* ExportAssignment */: + case 242 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 261 /* SourceFile */: + case 262 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent.kind === 241 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -65207,7 +65974,7 @@ var ts; // import a = |b.c|.d; // Namespace if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 234 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 235 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; @@ -65241,10 +66008,10 @@ var ts; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 255 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 256 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 226 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 227 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 227 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 228 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -65275,7 +66042,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 220 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -65285,13 +66052,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 215 /* BreakStatement */ || node.parent.kind === 214 /* ContinueStatement */) && + (node.parent.kind === 216 /* BreakStatement */ || node.parent.kind === 215 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 219 /* LabeledStatement */ && + node.parent.kind === 220 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -65307,7 +66074,7 @@ var ts; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 231 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -65320,13 +66087,13 @@ var ts; switch (node.parent.kind) { case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 260 /* EnumMember */: + case 258 /* PropertyAssignment */: + case 261 /* EnumMember */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return node.parent.name === node; case 178 /* ElementAccessExpression */: return node.parent.argumentExpression === node; @@ -65379,17 +66146,17 @@ var ts; return undefined; } switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return node; } } @@ -65397,22 +66164,22 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 227 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 228 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 229 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 223 /* VariableDeclaration */: + case 228 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 229 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 230 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 224 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); case 174 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; @@ -65428,15 +66195,15 @@ var ts; case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 260 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 261 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234 /* ImportEqualsDeclaration */: - case 239 /* ImportSpecifier */: - case 236 /* ImportClause */: - case 243 /* ExportSpecifier */: - case 237 /* NamespaceImport */: + case 235 /* ImportEqualsDeclaration */: + case 240 /* ImportSpecifier */: + case 237 /* ImportClause */: + case 244 /* ExportSpecifier */: + case 238 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -65511,19 +66278,19 @@ var ts; return false; } switch (n.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: case 172 /* ObjectBindingPattern */: case 161 /* TypeLiteral */: - case 204 /* Block */: - case 231 /* ModuleBlock */: - case 232 /* CaseBlock */: - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 205 /* Block */: + case 232 /* ModuleBlock */: + case 233 /* CaseBlock */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return isCompletedNode(n.block, sourceFile); case 180 /* NewExpression */: if (!n.arguments) { @@ -65540,7 +66307,7 @@ var ts; case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -65556,14 +66323,14 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 208 /* IfStatement */: + case 209 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); case 175 /* ArrayLiteralExpression */: @@ -65577,16 +66344,16 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 209 /* DoStatement */: + case 210 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { @@ -65607,10 +66374,10 @@ var ts; case 194 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202 /* TemplateSpan */: + case 203 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 241 /* ExportDeclaration */: - case 235 /* ImportDeclaration */: + case 242 /* ExportDeclaration */: + case 236 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); case 190 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); @@ -65672,7 +66439,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 292 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 293 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -65739,8 +66506,8 @@ var ts; } } // find the child that contains 'position' - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; // all jsDocComment nodes were already visited if (ts.isJSDocNode(child)) { continue; @@ -65819,7 +66586,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; // condition 'position < child.end' checks if child node end after the position // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' @@ -65844,7 +66611,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 262 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -65903,17 +66670,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 253 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 253 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 249 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 250 /* JsxClosingElement */) { return true; } return false; @@ -66028,7 +66795,7 @@ var ts; if (node.kind === 157 /* TypeReference */ || node.kind === 179 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 /* ClassDeclaration */ || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 227 /* ClassDeclaration */ || node.kind === 228 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -66105,7 +66872,7 @@ var ts; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 213 /* ForOfStatement */ && + if (node.parent.kind === 214 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -66113,7 +66880,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 258 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -66339,7 +67106,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 /* ImportSpecifier */ || location.parent.kind === 243 /* ExportSpecifier */) && + (location.parent.kind === 240 /* ImportSpecifier */ || location.parent.kind === 244 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -66406,6 +67173,11 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -66473,7 +67245,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -66845,10 +67617,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 231 /* ModuleDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -66899,7 +67671,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 /* ModuleDeclaration */ && + return declaration.kind === 231 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -66960,7 +67732,7 @@ var ts; ts.Debug.assert(classifications.spans.length % 3 === 0); var dense = classifications.spans; var result = []; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -67063,16 +67835,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 281 /* JSDocParameterTag */: + case 282 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 284 /* JSDocTemplateTag */: + case 285 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 283 /* JSDocTypeTag */: + case 284 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 282 /* JSDocReturnTag */: + case 283 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -67159,22 +67931,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248 /* JsxOpeningElement */: + case 249 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 249 /* JsxClosingElement */: + case 250 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 247 /* JsxSelfClosingElement */: + case 248 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 250 /* JsxAttribute */: + case 251 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -67202,10 +67974,10 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 223 /* VariableDeclaration */ || + if (token.parent.kind === 224 /* VariableDeclaration */ || token.parent.kind === 147 /* PropertyDeclaration */ || token.parent.kind === 144 /* Parameter */ || - token.parent.kind === 250 /* JsxAttribute */) { + token.parent.kind === 251 /* JsxAttribute */) { return 5 /* operator */; } } @@ -67222,7 +67994,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 250 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 251 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -67238,7 +68010,7 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -67248,17 +68020,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -67280,9 +68052,8 @@ var ts; // Ignore nodes that don't intersect the original span to classify. if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); @@ -67323,7 +68094,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 249 /* JsxClosingElement */) { + location.parent && location.parent.kind === 250 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -67350,14 +68121,14 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_44 in nameTable) { + for (var name_45 in nameTable) { // Skip identifiers produced only from the current location - if (nameTable[name_44] === position) { + if (nameTable[name_45] === position) { continue; } - if (!uniqueNames[name_44]) { - uniqueNames[name_44] = name_44; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, /*performCharacterChecks*/ true); + if (!uniqueNames[name_45]) { + uniqueNames[name_45] = name_45; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -67417,7 +68188,7 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression @@ -67443,7 +68214,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 235 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 236 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); @@ -67512,6 +68283,9 @@ var ts; return undefined; } function addStringLiteralCompletionsFromType(type, result) { + if (type && type.flags & 16384 /* TypeParameter */) { + type = typeChecker.getApparentType(type); + } if (!type) { return; } @@ -67870,11 +68644,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_13; + currentDir = parent_14; } else { break; @@ -68026,9 +68800,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283 /* JSDocTypeTag */: - case 281 /* JSDocParameterTag */: - case 282 /* JSDocReturnTag */: + case 284 /* JSDocTypeTag */: + case 282 /* JSDocParameterTag */: + case 283 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -68073,13 +68847,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_14.kind === 177 /* PropertyAccessExpression */) { + if (parent_15.kind === 177 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141 /* QualifiedName */) { + else if (parent_15.kind === 141 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -68094,7 +68868,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 249 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 250 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -68199,7 +68973,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247 /* JsxSelfClosingElement */) || (jsxContainer.kind === 248 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 248 /* JsxSelfClosingElement */) || (jsxContainer.kind === 249 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -68247,9 +69021,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 /* SourceFile */ || + scopeNode.kind === 262 /* SourceFile */ || scopeNode.kind === 194 /* TemplateExpression */ || - scopeNode.kind === 252 /* JsxExpression */ || + scopeNode.kind === 253 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -68282,11 +69056,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 248 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 249 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 249 /* JsxClosingElement */ || contextToken.parent.kind === 247 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246 /* JsxElement */; + if (contextToken.parent.kind === 250 /* JsxClosingElement */ || contextToken.parent.kind === 248 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 247 /* JsxElement */; } } return false; @@ -68316,16 +69090,16 @@ var ts; case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 230 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 231 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 226 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 227 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 223 /* VariableDeclaration */ // const x = a| + return containingNodeKind === 224 /* VariableDeclaration */ // const x = a| || containingNodeKind === 192 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 202 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 203 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: @@ -68439,9 +69213,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 /* NamedImports */ ? - 235 /* ImportDeclaration */ : - 241 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 239 /* NamedImports */ ? + 236 /* ImportDeclaration */ : + 242 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -68466,9 +69240,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 /* ObjectLiteralExpression */ || parent_15.kind === 172 /* ObjectBindingPattern */)) { - return parent_15; + var parent_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 /* ObjectLiteralExpression */ || parent_16.kind === 172 /* ObjectBindingPattern */)) { + return parent_16; } break; } @@ -68485,8 +69259,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 239 /* NamedImports */: + case 243 /* NamedExports */: return contextToken.parent; } } @@ -68495,37 +69269,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent_17 = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - if (parent_16 && (parent_16.kind === 247 /* JsxSelfClosingElement */ || parent_16.kind === 248 /* JsxOpeningElement */)) { - return parent_16; + case 251 /* JsxAttribute */: + case 252 /* JsxSpreadAttribute */: + if (parent_17 && (parent_17.kind === 248 /* JsxSelfClosingElement */ || parent_17.kind === 249 /* JsxOpeningElement */)) { + return parent_17; } - else if (parent_16.kind === 250 /* JsxAttribute */) { - return parent_16.parent; + else if (parent_17.kind === 251 /* JsxAttribute */) { + return parent_17.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_16 && ((parent_16.kind === 250 /* JsxAttribute */) || (parent_16.kind === 251 /* JsxSpreadAttribute */))) { - return parent_16.parent; + if (parent_17 && ((parent_17.kind === 251 /* JsxAttribute */) || (parent_17.kind === 252 /* JsxSpreadAttribute */))) { + return parent_17.parent; } break; case 17 /* CloseBraceToken */: - if (parent_16 && - parent_16.kind === 252 /* JsxExpression */ && - parent_16.parent && - (parent_16.parent.kind === 250 /* JsxAttribute */)) { - return parent_16.parent.parent; + if (parent_17 && + parent_17.kind === 253 /* JsxExpression */ && + parent_17.parent && + (parent_17.parent.kind === 251 /* JsxAttribute */)) { + return parent_17.parent.parent; } - if (parent_16 && parent_16.kind === 251 /* JsxSpreadAttribute */) { - return parent_16.parent; + if (parent_17 && parent_17.kind === 252 /* JsxSpreadAttribute */) { + return parent_17.parent; } break; } @@ -68536,7 +69310,7 @@ var ts; switch (kind) { case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -68555,16 +69329,16 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 223 /* VariableDeclaration */ || - containingNodeKind === 224 /* VariableDeclarationList */ || - containingNodeKind === 205 /* VariableStatement */ || - containingNodeKind === 229 /* EnumDeclaration */ || + return containingNodeKind === 224 /* VariableDeclaration */ || + containingNodeKind === 225 /* VariableDeclarationList */ || + containingNodeKind === 206 /* VariableStatement */ || + containingNodeKind === 230 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 226 /* ClassDeclaration */ || + containingNodeKind === 227 /* ClassDeclaration */ || containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || containingNodeKind === 173 /* ArrayBindingPattern */ || - containingNodeKind === 228 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 229 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: @@ -68572,22 +69346,22 @@ var ts; case 20 /* OpenBracketToken */: return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 256 /* CatchClause */ || + return containingNodeKind === 257 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 229 /* EnumDeclaration */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || + return containingNodeKind === 230 /* EnumDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || containingNodeKind === 161 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: return containingNodeKind === 146 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 228 /* InterfaceDeclaration */ || contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 226 /* ClassDeclaration */ || + return containingNodeKind === 227 /* ClassDeclaration */ || containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 228 /* TypeAliasDeclaration */ || + containingNodeKind === 228 /* InterfaceDeclaration */ || + containingNodeKind === 229 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: return containingNodeKind === 147 /* PropertyDeclaration */; @@ -68600,9 +69374,9 @@ var ts; case 112 /* ProtectedKeyword */: return containingNodeKind === 144 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 239 /* ImportSpecifier */ || - containingNodeKind === 243 /* ExportSpecifier */ || - containingNodeKind === 237 /* NamespaceImport */; + return containingNodeKind === 240 /* ImportSpecifier */ || + containingNodeKind === 244 /* ExportSpecifier */ || + containingNodeKind === 238 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: @@ -68662,8 +69436,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_45 = element.propertyName || element.name; - existingImportsOrExports[name_45.text] = true; + var name_46 = element.propertyName || element.name; + existingImportsOrExports[name_46.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -68684,8 +69458,8 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 257 /* PropertyAssignment */ && - m.kind !== 258 /* ShorthandPropertyAssignment */ && + if (m.kind !== 258 /* PropertyAssignment */ && + m.kind !== 259 /* ShorthandPropertyAssignment */ && m.kind !== 174 /* BindingElement */ && m.kind !== 149 /* MethodDeclaration */ && m.kind !== 151 /* GetAccessor */ && @@ -68727,7 +69501,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250 /* JsxAttribute */) { + if (attr.kind === 251 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -68908,58 +69682,58 @@ var ts; switch (node.kind) { case 89 /* IfKeyword */: case 81 /* ElseKeyword */: - if (hasKind(node.parent, 208 /* IfStatement */)) { + if (hasKind(node.parent, 209 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 216 /* ReturnStatement */)) { + if (hasKind(node.parent, 217 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 220 /* ThrowStatement */)) { + if (hasKind(node.parent, 221 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 221 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 222 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101 /* TryKeyword */: case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 221 /* TryStatement */)) { + if (hasKind(parent(node), 222 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 218 /* SwitchStatement */)) { + if (hasKind(node.parent, 219 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72 /* CaseKeyword */: case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 218 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 219 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71 /* BreakKeyword */: case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 215 /* BreakStatement */) || hasKind(node.parent, 214 /* ContinueStatement */)) { + if (hasKind(node.parent, 216 /* BreakStatement */) || hasKind(node.parent, 215 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87 /* ForKeyword */: - if (hasKind(node.parent, 211 /* ForStatement */) || - hasKind(node.parent, 212 /* ForInStatement */) || - hasKind(node.parent, 213 /* ForOfStatement */)) { + if (hasKind(node.parent, 212 /* ForStatement */) || + hasKind(node.parent, 213 /* ForInStatement */) || + hasKind(node.parent, 214 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105 /* WhileKeyword */: case 80 /* DoKeyword */: - if (hasKind(node.parent, 210 /* WhileStatement */) || hasKind(node.parent, 209 /* DoStatement */)) { + if (hasKind(node.parent, 211 /* WhileStatement */) || hasKind(node.parent, 210 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; @@ -68976,7 +69750,7 @@ var ts; break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 206 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -68992,10 +69766,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 220 /* ThrowStatement */) { + if (node.kind === 221 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 221 /* TryStatement */) { + else if (node.kind === 222 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -69022,19 +69796,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261 /* SourceFile */) { - return parent_17; + var parent_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 262 /* SourceFile */) { + return parent_18; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_17.kind === 221 /* TryStatement */) { - var tryStatement = parent_17; + if (parent_18.kind === 222 /* TryStatement */) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_17; + child = parent_18; } return undefined; } @@ -69043,7 +69817,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 /* BreakStatement */ || node.kind === 214 /* ContinueStatement */) { + if (node.kind === 216 /* BreakStatement */ || node.kind === 215 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -69056,25 +69830,25 @@ var ts; return actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { - for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 218 /* SwitchStatement */: - if (statement.kind === 214 /* ContinueStatement */) { + for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { + switch (node_2.kind) { + case 219 /* SwitchStatement */: + if (statement.kind === 215 /* ContinueStatement */) { continue; } // Fall through. - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: + if (!statement.label || isLabeledBy(node_2, statement.label.text)) { + return node_2; } break; default: // Don't cross function boundaries. - if (ts.isFunctionLike(node_1)) { + if (ts.isFunctionLike(node_2)) { return undefined; } break; @@ -69086,24 +69860,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 226 /* ClassDeclaration */ || + if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */ || (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { return undefined; } } else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { + if (!(container.kind === 227 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { return undefined; } } else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 231 /* ModuleBlock */ || container.kind === 261 /* SourceFile */)) { + if (!(container.kind === 232 /* ModuleBlock */ || container.kind === 262 /* SourceFile */)) { return undefined; } } else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || declaration.kind === 226 /* ClassDeclaration */)) { + if (!(container.kind === 227 /* ClassDeclaration */ || declaration.kind === 227 /* ClassDeclaration */)) { return undefined; } } @@ -69115,8 +69889,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: + case 232 /* ModuleBlock */: + case 262 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -69128,7 +69902,7 @@ var ts; case 150 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search @@ -69212,7 +69986,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 209 /* DoStatement */) { + if (loopNode.kind === 210 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { @@ -69233,13 +70007,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -69293,7 +70067,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 204 /* Block */))) { + if (!(func && hasKind(func.body, 205 /* Block */))) { return undefined; } var keywords = []; @@ -69309,7 +70083,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 208 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 209 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -69322,7 +70096,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 208 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 209 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -69365,7 +70139,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 220 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -69599,12 +70373,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 236 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 237 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 /* ImportSpecifier */ || - declaration.kind === 243 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 240 /* ImportSpecifier */ || + declaration.kind === 244 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -69612,7 +70386,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 239 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 240 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -69671,7 +70445,7 @@ var ts; if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 227 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -69702,7 +70476,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 262 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -69978,7 +70752,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 259 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -69991,24 +70765,24 @@ var ts; // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); + var parent_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204 /* Block */) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 205 /* Block */) { + ts.forEachReturnStatement(parent_19.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); + else if (isImplementationExpression(parent_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -70049,7 +70823,7 @@ var ts; function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { if (node.kind === 199 /* ExpressionWithTypeArguments */ - && node.parent.kind === 255 /* HeritageClause */ + && node.parent.kind === 256 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -70120,7 +70894,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { + else if (declaration.kind === 228 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -70200,12 +70974,12 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 261 /* SourceFile */: + case 262 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, @@ -70215,7 +70989,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 261 /* SourceFile */) { + if (searchSpaceNode.kind === 262 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -70250,7 +71024,7 @@ var ts; var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } @@ -70262,15 +71036,15 @@ var ts; } break; case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: // 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 261 /* SourceFile */: - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { + case 262 /* SourceFile */: + if (container.kind === 262 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -70306,13 +71080,13 @@ var ts; for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { var position = possiblePositions_1[_i]; cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { + var node_3 = ts.getTouchingWord(sourceFile, position); + if (!node_3 || node_3.kind !== 9 /* StringLiteral */) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + var type_1 = ts.getStringLiteralTypeForNode(node_3, typeChecker); if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + references.push(getReferenceEntryFromNode(node_3)); } } } @@ -70324,7 +71098,7 @@ var ts; // Search the property symbol // for ( { property: p2 } of elems) { } var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258 /* ShorthandPropertyAssignment */) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 259 /* ShorthandPropertyAssignment */) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -70427,7 +71201,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { + else if (declaration.kind === 228 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -70593,7 +71367,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223 /* VariableDeclaration */) { + else if (node.kind === 224 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -70603,18 +71377,18 @@ var ts; } else { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 224 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 206 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 225 /* VariableDeclarationList */); return node.parent.parent; } } @@ -70689,8 +71463,8 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 258 /* PropertyAssignment */: + case 259 /* ShorthandPropertyAssignment */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: @@ -70768,7 +71542,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 239 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 238 /* NamedImports */))) { + (declaration.kind === 240 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 239 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -70777,7 +71551,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -70861,7 +71635,7 @@ var ts; var definition; ts.forEach(signatureDeclarations, function (d) { if ((selectConstructors && d.kind === 150 /* Constructor */) || - (!selectConstructors && (d.kind === 225 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { + (!selectConstructors && (d.kind === 226 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -70941,7 +71715,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // 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 === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 259 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -71048,7 +71822,7 @@ var ts; */ function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -71108,19 +71882,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 150 /* Constructor */: - case 226 /* ClassDeclaration */: - case 205 /* VariableStatement */: + case 227 /* ClassDeclaration */: + case 206 /* VariableStatement */: break findOwner; - case 261 /* SourceFile */: + case 262 /* SourceFile */: return undefined; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 230 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 231 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -71135,7 +71909,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : @@ -71167,7 +71941,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205 /* VariableStatement */) { + if (commentOwner.kind === 206 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -71287,9 +72061,9 @@ var ts; } } // Add the cached typing locations for inferred typings that are already installed - for (var name_46 in packageNameToTypingLocation) { - if (name_46 in inferredTypings && !inferredTypings[name_46]) { - inferredTypings[name_46] = packageNameToTypingLocation[name_46]; + for (var name_47 in packageNameToTypingLocation) { + if (name_47 in inferredTypings && !inferredTypings[name_47]) { + inferredTypings[name_47] = packageNameToTypingLocation[name_47]; } } // Remove typings that the user has added to the exclude list @@ -71427,12 +72201,12 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + for (var name_48 in nameToDeclarations) { + var declarations = nameToDeclarations[name_48]; if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_48); if (!matches) { continue; } @@ -71445,14 +72219,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name_48); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_48, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -71460,7 +72234,7 @@ var ts; // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 /* ImportClause */ || decl.kind === 239 /* ImportSpecifier */ || decl.kind === 234 /* ImportEqualsDeclaration */) { + if (decl.kind === 237 /* ImportClause */ || decl.kind === 240 /* ImportSpecifier */ || decl.kind === 235 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -71715,7 +72489,7 @@ var ts; addLeafNode(node); } break; - case 236 /* ImportClause */: + case 237 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -71727,7 +72501,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 238 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -71739,11 +72513,11 @@ var ts; } break; case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name_49 = decl.name; + if (ts.isBindingPattern(name_49)) { + addChildrenRecursively(name_49); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -71754,11 +72528,11 @@ var ts; } break; case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -71768,9 +72542,9 @@ var ts; } endNode(); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -71778,21 +72552,21 @@ var ts; } endNode(); break; - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243 /* ExportSpecifier */: - case 234 /* ImportEqualsDeclaration */: + case 244 /* ExportSpecifier */: + case 235 /* ImportEqualsDeclaration */: case 155 /* IndexSignature */: case 153 /* CallSignature */: case 154 /* ConstructSignature */: - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285 /* JSDocTypedefTag */) { + if (tag.kind === 286 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -71843,14 +72617,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 231 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230 /* ModuleDeclaration */) { + if (a.body.kind !== 231 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -71910,7 +72684,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 231 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -71922,14 +72696,14 @@ var ts; case 185 /* ArrowFunction */: case 197 /* ClassExpression */: return getFunctionOrClassName(node); - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 231 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -71940,15 +72714,15 @@ var ts; } } switch (node.kind) { - case 261 /* SourceFile */: + case 262 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; @@ -71965,7 +72739,7 @@ var ts; return "()"; case 155 /* IndexSignature */: return "[]"; - case 285 /* JSDocTypedefTag */: + case 286 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -71977,7 +72751,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 206 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -72006,23 +72780,23 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: - case 228 /* TypeAliasDeclaration */: - case 285 /* JSDocTypedefTag */: + case 230 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 231 /* ModuleDeclaration */: + case 262 /* SourceFile */: + case 229 /* TypeAliasDeclaration */: + case 286 /* JSDocTypedefTag */: return true; case 150 /* Constructor */: case 149 /* MethodDeclaration */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: return hasSomeImportantChild(item); case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: @@ -72033,8 +72807,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: + case 232 /* ModuleBlock */: + case 262 /* SourceFile */: case 149 /* MethodDeclaration */: case 150 /* Constructor */: return true; @@ -72045,7 +72819,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; + return childKind !== 224 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; }); } } @@ -72103,7 +72877,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 231 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -72114,13 +72888,13 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 230 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 231 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { return !member.name || member.name.kind === 142 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 261 /* SourceFile */ + return node.kind === 262 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -72128,14 +72902,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223 /* VariableDeclaration */) { + else if (node.parent.kind === 224 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } else if (node.parent.kind === 192 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -72248,30 +73022,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204 /* Block */: + case 205 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent_20 = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_19.kind === 209 /* DoStatement */ || - parent_19.kind === 212 /* ForInStatement */ || - parent_19.kind === 213 /* ForOfStatement */ || - parent_19.kind === 211 /* ForStatement */ || - parent_19.kind === 208 /* IfStatement */ || - parent_19.kind === 210 /* WhileStatement */ || - parent_19.kind === 217 /* WithStatement */ || - parent_19.kind === 256 /* CatchClause */) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent_20.kind === 210 /* DoStatement */ || + parent_20.kind === 213 /* ForInStatement */ || + parent_20.kind === 214 /* ForOfStatement */ || + parent_20.kind === 212 /* ForStatement */ || + parent_20.kind === 209 /* IfStatement */ || + parent_20.kind === 211 /* WhileStatement */ || + parent_20.kind === 218 /* WithStatement */ || + parent_20.kind === 257 /* CatchClause */) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221 /* TryStatement */) { + if (parent_20.kind === 222 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_19; + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -72294,17 +73068,17 @@ var ts; break; } // Fallthrough. - case 231 /* ModuleBlock */: { + case 232 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 176 /* ObjectLiteralExpression */: - case 232 /* CaseBlock */: { + case 233 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); @@ -72690,7 +73464,8 @@ var ts; } // Assumes 'value' is already lowercase. function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -72699,7 +73474,7 @@ var ts; } // Assumes 'value' is already lowercase. function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -72771,7 +73546,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -73597,7 +74372,7 @@ var ts; var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 203 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; @@ -73728,7 +74503,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 262 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -74124,7 +74899,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 231 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -74161,7 +74936,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 228 /* TypeAliasDeclaration */) { + else if (declaration.kind === 229 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -74177,7 +74952,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260 /* EnumMember */) { + if (declaration.kind === 261 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -74189,7 +74964,7 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 234 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); @@ -74200,7 +74975,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234 /* ImportEqualsDeclaration */) { + if (declaration.kind === 235 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -74273,7 +75048,7 @@ var ts; // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 262 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 192 /* BinaryExpression */) { @@ -74360,13 +75135,13 @@ var ts; if (declaration.kind === 184 /* FunctionExpression */) { return true; } - if (declaration.kind !== 223 /* VariableDeclaration */ && declaration.kind !== 225 /* FunctionDeclaration */) { + if (declaration.kind !== 224 /* VariableDeclaration */ && declaration.kind !== 226 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { + for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { // Reached source file or module block - if (parent_20.kind === 261 /* SourceFile */ || parent_20.kind === 231 /* ModuleBlock */) { + if (parent_21.kind === 262 /* SourceFile */ || parent_21.kind === 232 /* ModuleBlock */) { return false; } } @@ -74604,10 +75379,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 250 /* JsxAttribute */: - case 248 /* JsxOpeningElement */: - case 249 /* JsxClosingElement */: - case 247 /* JsxSelfClosingElement */: + case 251 /* JsxAttribute */: + case 249 /* JsxOpeningElement */: + case 250 /* JsxClosingElement */: + case 248 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -75019,11 +75794,11 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 140 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75040,10 +75815,10 @@ var ts; this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); @@ -75073,6 +75848,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109 /* LetKeyword */, 75 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75089,11 +75865,12 @@ var ts; this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); @@ -75130,6 +75907,8 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + // No space before non-null assertion operator + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -75160,7 +75939,7 @@ var ts; this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, // TypeScript-specific rules - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -75175,6 +75954,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; // These rules are lower in priority than user-configurable rules. this.LowPriorityCommonRules = [ @@ -75184,7 +75964,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; /// @@ -75242,9 +76021,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name_50 in o) { + if (o[name_50] === rule) { + return name_50; } } throw new Error("Unknown rule"); @@ -75253,7 +76032,7 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 211 /* ForStatement */; + return context.contextNode.kind === 212 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); @@ -75263,8 +76042,8 @@ var ts; case 192 /* BinaryExpression */: case 193 /* ConditionalExpression */: case 200 /* AsExpression */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: case 156 /* TypePredicate */: case 164 /* UnionType */: case 165 /* IntersectionType */: @@ -75272,22 +76051,24 @@ var ts; // equals in binding elements: function foo([[x, y] = [1, 2]]) case 174 /* BindingElement */: // equals in type X = ... - case 228 /* TypeAliasDeclaration */: + case 229 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: // equal in p = 0; case 144 /* Parameter */: - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: + // "in" keyword in [P in keyof T]: T[P] + case 143 /* TypeParameter */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; } return false; @@ -75317,6 +76098,9 @@ var ts; //// * ) and { are on different lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 172 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); + }; // This check is done before an open brace in a control construct, a function, or a typescript block declaration Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -75340,17 +76124,17 @@ var ts; return true; } switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: + case 205 /* Block */: + case 233 /* CaseBlock */: case 176 /* ObjectLiteralExpression */: - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -75364,60 +76148,66 @@ var ts; // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 227 /* InterfaceDeclaration */: + case 228 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; + return context.contextNode.kind === 226 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: case 161 /* TypeLiteral */: - case 230 /* ModuleDeclaration */: - case 241 /* ExportDeclaration */: - case 242 /* NamedExports */: - case 235 /* ImportDeclaration */: - case 238 /* NamedImports */: + case 231 /* ModuleDeclaration */: + case 242 /* ExportDeclaration */: + case 243 /* NamedExports */: + case 236 /* ImportDeclaration */: + case 239 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226 /* ClassDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 204 /* Block */: - case 256 /* CatchClause */: - case 231 /* ModuleBlock */: - case 218 /* SwitchStatement */: + case 227 /* ClassDeclaration */: + case 231 /* ModuleDeclaration */: + case 230 /* EnumDeclaration */: + case 257 /* CatchClause */: + case 232 /* ModuleBlock */: + case 219 /* SwitchStatement */: return true; + case 205 /* Block */: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 185 /* ArrowFunction */ && + blockParent.kind !== 184 /* FunctionExpression */) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208 /* IfStatement */: - case 218 /* SwitchStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 221 /* TryStatement */: - case 209 /* DoStatement */: - case 217 /* WithStatement */: + case 209 /* IfStatement */: + case 219 /* SwitchStatement */: + case 212 /* ForStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 222 /* TryStatement */: + case 210 /* DoStatement */: + case 218 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 256 /* CatchClause */: + case 257 /* CatchClause */: return true; default: return false; @@ -75448,19 +76238,19 @@ var ts; return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246 /* JsxElement */; + return context.contextNode.kind !== 247 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252 /* JsxExpression */; + return context.contextNode.kind === 253 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250 /* JsxAttribute */; + return context.nextTokenParent.kind === 251 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250 /* JsxAttribute */; + return context.contextNode.kind === 251 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247 /* JsxSelfClosingElement */; + return context.contextNode.kind === 248 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -75478,14 +76268,14 @@ var ts; return node.kind === 145 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 225 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230 /* ModuleDeclaration */; + return context.contextNode.kind === 231 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -75497,10 +76287,11 @@ var ts; switch (parent.kind) { case 157 /* TypeReference */: case 182 /* TypeAssertionExpression */: - case 226 /* ClassDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 228 /* InterfaceDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: @@ -75528,6 +76319,9 @@ var ts; Rules.IsYieldOrYieldStarWithOperand = function (context) { return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 201 /* NonNullExpression */; + }; return Rules; }()); formatting.Rules = Rules; @@ -75846,6 +76640,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -75926,6 +76726,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -76058,17 +76864,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 227 /* ClassDeclaration */: + case 228 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 231 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 261 /* SourceFile */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + return body && body.kind === 232 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 262 /* SourceFile */: + case 205 /* Block */: + case 232 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -76273,10 +77079,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 227 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 225 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 229 /* EnumDeclaration */: return 229 /* EnumDeclaration */; + case 227 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 228 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 226 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 230 /* EnumDeclaration */: return 230 /* EnumDeclaration */; case 151 /* GetAccessor */: return 124 /* GetKeyword */; case 152 /* SetAccessor */: return 133 /* SetKeyword */; case 149 /* MethodDeclaration */: @@ -76316,18 +77122,31 @@ var ts; // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent case 16 /* OpenBraceToken */: case 17 /* CloseBraceToken */: - case 20 /* OpenBracketToken */: - case 21 /* CloseBracketToken */: case 18 /* OpenParenToken */: case 19 /* CloseParenToken */: case 81 /* ElseKeyword */: case 105 /* WhileKeyword */: case 56 /* AtToken */: return indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40 /* SlashToken */: + case 28 /* GreaterThanToken */: { + if (container.kind === 249 /* JsxOpeningElement */ || + container.kind === 250 /* JsxClosingElement */ || + container.kind === 248 /* JsxSelfClosingElement */) { + return indentation; + } + break; + } + case 20 /* OpenBracketToken */: + case 21 /* CloseBracketToken */: { + if (container.kind !== 170 /* MappedType */) { + return indentation; + } + break; + } } + // if token line equals to the line of containing node (this is a first token in the node) - use node indentation + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -76383,7 +77202,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -76417,7 +77236,7 @@ var ts; // stop when formatting scanner advances past the beginning of the child break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -76457,11 +77276,11 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -76479,7 +77298,7 @@ var ts; // without this check close paren will be interpreted as list end token for function expression which is wrong if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -76686,7 +77505,7 @@ var ts; } // shift all parts on the delta size var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -76792,7 +77611,7 @@ var ts; function getOpenTokenForList(node, list) { switch (node.kind) { case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -77052,7 +77871,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 261 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 262 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -77085,7 +77904,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 209 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -77107,7 +77926,7 @@ var ts; return node.parent.properties; case 175 /* ArrayLiteralExpression */: return node.parent.elements; - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: @@ -77241,35 +78060,36 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207 /* ExpressionStatement */: - case 226 /* ClassDeclaration */: + case 208 /* ExpressionStatement */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 230 /* EnumDeclaration */: + case 229 /* TypeAliasDeclaration */: case 175 /* ArrayLiteralExpression */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 205 /* Block */: + case 232 /* ModuleBlock */: case 176 /* ObjectLiteralExpression */: case 161 /* TypeLiteral */: + case 170 /* MappedType */: case 163 /* TupleType */: - case 232 /* CaseBlock */: - case 254 /* DefaultClause */: - case 253 /* CaseClause */: + case 233 /* CaseBlock */: + case 255 /* DefaultClause */: + case 254 /* CaseClause */: case 183 /* ParenthesizedExpression */: case 177 /* PropertyAccessExpression */: case 179 /* CallExpression */: case 180 /* NewExpression */: - case 205 /* VariableStatement */: - case 223 /* VariableDeclaration */: - case 240 /* ExportAssignment */: - case 216 /* ReturnStatement */: + case 206 /* VariableStatement */: + case 224 /* VariableDeclaration */: + case 241 /* ExportAssignment */: + case 217 /* ReturnStatement */: case 193 /* ConditionalExpression */: case 173 /* ArrayBindingPattern */: case 172 /* ObjectBindingPattern */: - case 248 /* JsxOpeningElement */: - case 247 /* JsxSelfClosingElement */: - case 252 /* JsxExpression */: + case 249 /* JsxOpeningElement */: + case 248 /* JsxSelfClosingElement */: + case 253 /* JsxExpression */: case 148 /* MethodSignature */: case 153 /* CallSignature */: case 154 /* ConstructSignature */: @@ -77279,10 +78099,10 @@ var ts; case 166 /* ParenthesizedType */: case 181 /* TaggedTemplateExpression */: case 189 /* AwaitExpression */: - case 242 /* NamedExports */: - case 238 /* NamedImports */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 243 /* NamedExports */: + case 239 /* NamedImports */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: return true; } return false; @@ -77291,27 +78111,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 208 /* IfStatement */: - case 225 /* FunctionDeclaration */: + case 210 /* DoStatement */: + case 211 /* WhileStatement */: + case 213 /* ForInStatement */: + case 214 /* ForOfStatement */: + case 212 /* ForStatement */: + case 209 /* IfStatement */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 185 /* ArrowFunction */: case 150 /* Constructor */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: - return childKind !== 204 /* Block */; - case 241 /* ExportDeclaration */: - return childKind !== 242 /* NamedExports */; - case 235 /* ImportDeclaration */: - return childKind !== 236 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 238 /* NamedImports */); - case 246 /* JsxElement */: - return childKind !== 249 /* JsxClosingElement */; + return childKind !== 205 /* Block */; + case 242 /* ExportDeclaration */: + return childKind !== 243 /* NamedExports */; + case 236 /* ImportDeclaration */: + return childKind !== 237 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 239 /* NamedImports */); + case 247 /* JsxElement */: + return childKind !== 250 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -77367,25 +78187,128 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122 /* ConstructorKeyword */) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1 /* Number */); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0 /* String */); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1 /* Number */, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0 /* String */, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_7 = writer.string(); + ts.releaseStringWriter(writer); + return result_7; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + // This is the identifier in the case of a class declaration + // or the class keyword token in the case of a class expression. + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -77409,7 +78332,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -77425,7 +78348,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 208 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -77439,6 +78362,227 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122 /* ConstructorKeyword */) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 /* Identifier */ && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84 /* ExtendsKeyword */)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + // We replace existing keywords with commas. + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + // this handles var ["computed"] = 12; + if (token.kind === 20 /* OpenBracketToken */) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70 /* Identifier */: + switch (token.parent.kind) { + case 224 /* VariableDeclaration */: + switch (token.parent.parent.parent.kind) { + case 212 /* ForStatement */: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 214 /* ForOfStatement */: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 225 /* VariableDeclarationList */) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 213 /* ForInStatement */: + // There is no valid fix in the case of: + // for .. in + return undefined; + case 257 /* CatchClause */: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143 /* TypeParameter */: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144 /* Parameter */: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + // handle case where 'import a = A;' + case 235 /* ImportEqualsDeclaration */: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 240 /* ImportSpecifier */: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + // Only 1 import and it is unused. So the entire declaration should be removed. + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + // handle case where "import d, * as ns from './file'" + // or "'import {a, b as ns} from './file'" + case 237 /* ImportClause */: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 238 /* NamespaceImport */: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147 /* PropertyDeclaration */: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 238 /* NamespaceImport */: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 236 /* ImportDeclaration */ && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + 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); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -77538,7 +78682,10 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -77550,6 +78697,11 @@ var ts; // this is a module id -> module import declaration map var cachedImportDeclarations = ts.createMap(); var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -77557,7 +78709,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -77597,10 +78748,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 236 /* ImportDeclaration */) { return node; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 235 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -77618,7 +78769,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { // With an existing import statement, there are more than one actions the user can do. @@ -77646,9 +78797,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { var declaration = declarations_11[_i]; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 236 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 238 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -77672,7 +78823,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { /** * If the existing import declaration already has a named import list, just @@ -77688,7 +78839,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 246 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -77736,7 +78887,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 236 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -77773,7 +78924,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; // 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. @@ -77793,7 +78946,7 @@ var ts; tryGetModuleNameAsNodeModule() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 262 /* SourceFile */) { return moduleSymbol.name; } } @@ -77806,6 +78959,7 @@ var ts; if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -77825,7 +78979,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -77947,156 +79101,149 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - // this handles var ["computed"] = 12; - if (token.kind === 20 /* OpenBracketToken */) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70 /* Identifier */: - switch (token.parent.kind) { - case 223 /* VariableDeclaration */: - switch (token.parent.parent.parent.kind) { - case 211 /* ForStatement */: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213 /* ForOfStatement */: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212 /* ForInStatement */: - // There is no valid fix in the case of: - // for .. in - return undefined; - case 256 /* CatchClause */: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143 /* TypeParameter */: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144 /* Parameter */: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - // handle case where 'import a = A;' - case 234 /* ImportEqualsDeclaration */: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239 /* ImportSpecifier */: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - // Only 1 import and it is unused. So the entire declaration should be removed. - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - // handle case where "import d, * as ns from './file'" - // or "'import {a, b as ns} from './file'" - case 236 /* ImportClause */: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237 /* NamespaceImport */: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147 /* PropertyDeclaration */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237 /* NamespaceImport */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 /* ImportDeclaration */ && importDecl.parent) { - importDecl = importDecl.parent; + /** + * Finds members of the resolved type that are missing in the class pointed to by class decl + * and generates source code for the missing members. + * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. + * @returns Empty string iff there are no member insertions. + */ + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !(symbol.getName() in classMembers); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + /** + * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. + */ + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + // const name = symbol.getName(); + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 146 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 148 /* MethodSignature */: + case 149 /* MethodDeclaration */: + // The signature for the implementation appears as an entry in `signatures` iff + // there is only one signature. + // If there are overloads and an implementation signature, it appears as an + // extra declaration that isn't a signature for `type`. + // 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. + var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + // If there is a declaration with a body, it is the last declaration, + // and it isn't caught by `getSignaturesOfType`. + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(153 /* CallSignature */); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54 /* QuestionToken */); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23 /* DotDotDotToken */); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(144 /* Parameter */); + newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4 /* Public */) { + return "public "; + } + else if (flags & 16 /* Protected */) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// /// /// /// @@ -78122,7 +79269,7 @@ var ts; /// /// /// -/// +/// /// var ts; (function (ts) { @@ -78187,7 +79334,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(293 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -78210,7 +79357,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 /* FirstJSDocTagNode */ && this.kind <= 291 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 279 /* FirstJSDocTagNode */ && this.kind <= 292 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -78489,9 +79636,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_7 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_7 !== undefined) { - return result_7; + var result_8 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_8 !== undefined) { + return result_8; } if (declaration.name.kind === 142 /* ComputedPropertyName */) { var expr = declaration.name.expression; @@ -78515,7 +79662,7 @@ var ts; } function visit(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 184 /* FunctionExpression */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: @@ -78538,18 +79685,18 @@ var ts; } ts.forEachChild(node, visit); break; - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: + case 230 /* EnumDeclaration */: + case 231 /* ModuleDeclaration */: + case 235 /* ImportEqualsDeclaration */: + case 244 /* ExportSpecifier */: + case 240 /* ImportSpecifier */: + case 235 /* ImportEqualsDeclaration */: + case 237 /* ImportClause */: + case 238 /* NamespaceImport */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 161 /* TypeLiteral */: @@ -78562,7 +79709,7 @@ var ts; break; } // fall through - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 174 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { @@ -78572,19 +79719,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260 /* EnumMember */: + case 261 /* EnumMember */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: addDeclaration(node); break; - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -78596,7 +79743,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 238 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -79297,7 +80444,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 230 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 231 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -79529,7 +80676,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -79683,7 +80830,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 245 /* ExternalModuleReference */ || + node.parent.kind === 246 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -79787,16 +80934,16 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 206 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223 /* VariableDeclaration */: + case 224 /* VariableDeclaration */: case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: return spanInVariableDeclaration(node); case 144 /* Parameter */: return spanInParameterDeclaration(node); - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: @@ -79805,85 +80952,85 @@ var ts; case 184 /* FunctionExpression */: case 185 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 204 /* Block */: + case 205 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: return spanInBlock(node); - case 256 /* CatchClause */: + case 257 /* CatchClause */: return spanInBlock(node.block); - case 207 /* ExpressionStatement */: + case 208 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 216 /* ReturnStatement */: + case 217 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 210 /* WhileStatement */: + case 211 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* DoStatement */: + case 210 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 222 /* DebuggerStatement */: + case 223 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 208 /* IfStatement */: + case 209 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 219 /* LabeledStatement */: + case 220 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 216 /* BreakStatement */: + case 215 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 211 /* ForStatement */: + case 212 /* ForStatement */: return spanInForStatement(node); - case 212 /* ForInStatement */: + case 213 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 213 /* ForOfStatement */: + case 214 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 218 /* SwitchStatement */: + case 219 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 254 /* CaseClause */: + case 255 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 221 /* TryStatement */: + case 222 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 220 /* ThrowStatement */: + case 221 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 240 /* ExportAssignment */: + case 241 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 235 /* ImportDeclaration */: + case 236 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 241 /* ExportDeclaration */: + case 242 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: + case 227 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 261 /* EnumMember */: case 174 /* BindingElement */: // span on complete node return textSpan(node); - case 217 /* WithStatement */: + case 218 /* WithStatement */: // span in statement return spanInNode(node.statement); case 145 /* Decorator */: @@ -79892,8 +81039,8 @@ var ts; case 173 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* InterfaceDeclaration */: + case 229 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -79937,8 +81084,8 @@ var ts; // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 70 /* Identifier */ || node.kind == 196 /* SpreadElement */ || - node.kind === 257 /* PropertyAssignment */ || - node.kind === 258 /* ShorthandPropertyAssignment */) && + node.kind === 258 /* PropertyAssignment */ || + node.kind === 259 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } @@ -79965,14 +81112,14 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209 /* DoStatement */: + case 210 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 145 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: return textSpan(node); case 192 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { @@ -79989,7 +81136,7 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 258 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); @@ -80003,7 +81150,7 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 223 /* VariableDeclaration */ || + if ((node.parent.kind === 224 /* VariableDeclaration */ || node.parent.kind === 144 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || @@ -80038,7 +81185,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 212 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 213 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -80049,7 +81196,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 213 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 214 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -80089,7 +81236,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 226 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); + (functionDeclaration.parent.kind === 227 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -80112,25 +81259,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230 /* ModuleDeclaration */: + case 231 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 210 /* WhileStatement */: - case 208 /* IfStatement */: - case 212 /* ForInStatement */: + case 211 /* WhileStatement */: + case 209 /* IfStatement */: + case 213 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 225 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -80184,13 +81331,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229 /* EnumDeclaration */: + case 230 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226 /* ClassDeclaration */: + case 227 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -80198,24 +81345,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231 /* ModuleBlock */: + case 232 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 229 /* EnumDeclaration */: - case 226 /* ClassDeclaration */: + case 230 /* EnumDeclaration */: + case 227 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 204 /* Block */: + case 205 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 256 /* CatchClause */: + case 257 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232 /* CaseBlock */: + case 233 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -80254,7 +81401,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 /* DoStatement */ || + if (node.parent.kind === 210 /* DoStatement */ || node.parent.kind === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { return spanInPreviousNode(node); @@ -80269,17 +81416,17 @@ var ts; // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 226 /* FunctionDeclaration */: case 185 /* ArrowFunction */: case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: case 151 /* GetAccessor */: case 152 /* SetAccessor */: case 150 /* Constructor */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 211 /* WhileStatement */: + case 210 /* DoStatement */: + case 212 /* ForStatement */: + case 214 /* ForOfStatement */: case 179 /* CallExpression */: case 180 /* NewExpression */: case 183 /* ParenthesizedExpression */: @@ -80292,7 +81439,7 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 /* PropertyAssignment */ || + node.parent.kind === 258 /* PropertyAssignment */ || node.parent.kind === 144 /* Parameter */) { return spanInPreviousNode(node); } @@ -80305,7 +81452,7 @@ var ts; return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209 /* DoStatement */) { + if (node.parent.kind === 210 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -80313,7 +81460,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.kind === 214 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -81102,7 +82249,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index d8cd324a8d2..47b04ae9e58 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 ts; (function (ts) { var OperationCanceledException = (function () { @@ -206,7 +211,7 @@ var ts; ts.toPath = toPath; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +230,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +240,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -245,7 +250,7 @@ var ts; } ts.find = find; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +273,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +283,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -981,6 +986,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2475,7 +2481,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, @@ -2632,6 +2638,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2861,6 +2868,8 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2870,6 +2879,7 @@ var ts; Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, @@ -2921,6 +2931,8 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -3089,6 +3101,7 @@ var ts; Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,10 +3115,10 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, @@ -3154,6 +3167,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3210,22 +3225,25 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers." }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3606,7 +3624,7 @@ var ts; if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { var ch = text.charCodeAt(pos); if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +3810,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -5539,6 +5557,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -6102,6 +6121,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -6109,9 +6134,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -6123,13 +6145,13 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { - case 2: - case 0: + case Extensions.DtsOnly: + case Extensions.TypeScript: return tryReadFromField("typings") || tryReadFromField("types"); - case 1: + case Extensions.JavaScript: if (typeof jsonContent.main === "string") { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); @@ -6191,6 +6213,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -6245,7 +6268,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -6261,7 +6288,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -6302,31 +6330,115 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + if (!perModuleNameCache) { + moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent_1 = ts.getDirectoryPath(current); + if (parent_1 === current || directoryPathMap.contains(parent_1)) { + break; + } + directoryPathMap.set(parent_1, result); + current = parent_1; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache[moduleName]; + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache[moduleName] = result; + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -6451,33 +6563,33 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } @@ -6494,10 +6606,33 @@ var ts; } function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6525,11 +6660,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -6538,19 +6673,21 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } } - failedLookupLocations.push(fileName); - return undefined; } + failedLookupLocations.push(fileName); + return undefined; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); @@ -6559,16 +6696,22 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); + var mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); + if (mainOrTypesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(mainOrTypesFile), state.host); + var fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromExactFile) { + var resolved_3 = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); + if (resolved_3) { + return resolved_3; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + var resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved) { + return resolved; } } else { @@ -6578,73 +6721,117 @@ var ts; } } else { - if (state.traceEnabled) { + if (directoryExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_3) { - return resolved_3; + if (resolved_4) { + return resolved_4; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -6656,10 +6843,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); From 32b3436286d7d8ab323a674258df04d2a7d67c60 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 5 Jan 2017 11:35:33 -0800 Subject: [PATCH 057/175] Add builder.ts to server sources --- Jakefile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Jakefile.js b/Jakefile.js index 093d6f16893..a786fb16ed3 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -184,6 +184,7 @@ var servicesSources = [ })); var baseServerCoreSources = [ + "builder.ts", "editorServices.ts", "lsHost.ts", "project.ts", From 1978c5b07dffd3ba57e2644de4f9f1288c1f624c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 5 Jan 2017 11:58:24 -0800 Subject: [PATCH 058/175] Update LKG --- lib/tsserver.js | 2082 ++++---- lib/tsserverlibrary.d.ts | 10509 ++++++------------------------------- lib/tsserverlibrary.js | 3332 ++++++------ 3 files changed, 4186 insertions(+), 11737 deletions(-) diff --git a/lib/tsserver.js b/lib/tsserver.js index 2d477ca2dcf..10cfa276fec 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -6112,200 +6112,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - var LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(LogLevel = server.LogLevel || (server.LogLevel = {})); - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(true), - compilerOptions: project.getCompilerOptions(), - typeAcquisition: typeAcquisition, - unresolvedImports: unresolvedImports, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - 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, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - function toSortedReadonlyArray(arr) { - arr.sort(); - return arr; - } - server.toSortedReadonlyArray = toSortedReadonlyArray; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); @@ -65709,6 +65515,1047 @@ var ts; initializeServices(); })(ts || (ts = {})); var ts; +(function (ts) { + var server; + (function (server) { + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(true), + compilerOptions: project.getCompilerOptions(), + typeAcquisition: typeAcquisition, + unresolvedImports: unresolvedImports, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + 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, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + function toSortedReadonlyArray(arr) { + arr.sort(); + return arr; + } + server.toSortedReadonlyArray = toSortedReadonlyArray; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var lineCollectionCapacity = 4; + var CharRangeSection; + (function (CharRangeSection) { + CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; + CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; + CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; + CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; + CharRangeSection[CharRangeSection["End"] = 4] = "End"; + CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; + })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); + var BaseLineIndexWalker = (function () { + function BaseLineIndexWalker() { + this.goSubtree = true; + this.done = false; + } + BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { + }; + return BaseLineIndexWalker; + }()); + var EditWalker = (function (_super) { + __extends(EditWalker, _super); + function EditWalker() { + var _this = _super.call(this) || this; + _this.lineIndex = new LineIndex(); + _this.endBranch = []; + _this.state = CharRangeSection.Entire; + _this.initialText = ""; + _this.trailingText = ""; + _this.suppressTrailingText = false; + _this.lineIndex.root = new LineNode(); + _this.startPath = [_this.lineIndex.root]; + _this.stack = [_this.lineIndex.root]; + return _this; + } + EditWalker.prototype.insertLines = function (insertedText) { + if (this.suppressTrailingText) { + this.trailingText = ""; + } + if (insertedText) { + insertedText = this.initialText + insertedText + this.trailingText; + } + else { + insertedText = this.initialText + this.trailingText; + } + var lm = LineIndex.linesFromText(insertedText); + var lines = lm.lines; + if (lines.length > 1) { + if (lines[lines.length - 1] == "") { + lines.length--; + } + } + var branchParent; + var lastZeroCount; + for (var k = this.endBranch.length - 1; k >= 0; k--) { + this.endBranch[k].updateCounts(); + if (this.endBranch[k].charCount() === 0) { + lastZeroCount = this.endBranch[k]; + if (k > 0) { + branchParent = this.endBranch[k - 1]; + } + else { + branchParent = this.branchNode; + } + } + } + if (lastZeroCount) { + branchParent.remove(lastZeroCount); + } + var insertionNode = this.startPath[this.startPath.length - 2]; + var leafNode = this.startPath[this.startPath.length - 1]; + var len = lines.length; + if (len > 0) { + leafNode.text = lines[0]; + if (len > 1) { + var insertedNodes = new Array(len - 1); + var startNode = leafNode; + for (var i = 1; i < lines.length; i++) { + insertedNodes[i - 1] = new LineLeaf(lines[i]); + } + var pathIndex = this.startPath.length - 2; + while (pathIndex >= 0) { + insertionNode = this.startPath[pathIndex]; + insertedNodes = insertionNode.insertAt(startNode, insertedNodes); + pathIndex--; + startNode = insertionNode; + } + var insertedNodesLen = insertedNodes.length; + while (insertedNodesLen > 0) { + var newRoot = new LineNode(); + newRoot.add(this.lineIndex.root); + insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); + insertedNodesLen = insertedNodes.length; + this.lineIndex.root = newRoot; + } + this.lineIndex.root.updateCounts(); + } + else { + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + } + else { + insertionNode.remove(leafNode); + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + return this.lineIndex; + }; + EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { + if (lineCollection === this.lineCollectionAtBranch) { + this.state = CharRangeSection.End; + } + this.stack.length--; + return undefined; + }; + EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { + var currentNode = this.stack[this.stack.length - 1]; + if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { + this.state = CharRangeSection.Start; + this.branchNode = currentNode; + this.lineCollectionAtBranch = lineCollection; + } + var child; + function fresh(node) { + if (node.isLeaf()) { + return new LineLeaf(""); + } + else + return new LineNode(); + } + switch (nodeType) { + case CharRangeSection.PreStart: + this.goSubtree = false; + if (this.state !== CharRangeSection.End) { + currentNode.add(lineCollection); + } + break; + case CharRangeSection.Start: + if (this.state === CharRangeSection.End) { + this.goSubtree = false; + } + else { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + break; + case CharRangeSection.Entire: + if (this.state !== CharRangeSection.End) { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.Mid: + this.goSubtree = false; + break; + case CharRangeSection.End: + if (this.state !== CharRangeSection.End) { + this.goSubtree = false; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.PostEnd: + this.goSubtree = false; + if (this.state !== CharRangeSection.Start) { + currentNode.add(lineCollection); + } + break; + } + if (this.goSubtree) { + this.stack[this.stack.length] = child; + } + return lineCollection; + }; + EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { + if (this.state === CharRangeSection.Start) { + this.initialText = ll.text.substring(0, relativeStart); + } + else if (this.state === CharRangeSection.Entire) { + this.initialText = ll.text.substring(0, relativeStart); + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + else { + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + }; + return EditWalker; + }(BaseLineIndexWalker)); + var TextChange = (function () { + function TextChange(pos, deleteLen, insertedText) { + this.pos = pos; + this.deleteLen = deleteLen; + this.insertedText = insertedText; + } + TextChange.prototype.getTextChangeRange = function () { + return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); + }; + return TextChange; + }()); + server.TextChange = TextChange; + var ScriptVersionCache = (function () { + function ScriptVersionCache() { + this.changes = []; + this.versions = new Array(ScriptVersionCache.maxVersions); + this.minVersion = 0; + this.currentVersion = 0; + } + ScriptVersionCache.prototype.versionToIndex = function (version) { + if (version < this.minVersion || version > this.currentVersion) { + return undefined; + } + return version % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.currentVersionToIndex = function () { + return this.currentVersion % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { + this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); + if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || + (deleteLen > ScriptVersionCache.changeLengthThreshold) || + (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { + this.getSnapshot(); + } + }; + ScriptVersionCache.prototype.latest = function () { + return this.versions[this.currentVersionToIndex()]; + }; + ScriptVersionCache.prototype.latestVersion = function () { + if (this.changes.length > 0) { + this.getSnapshot(); + } + return this.currentVersion; + }; + ScriptVersionCache.prototype.reloadFromFile = function (filename) { + var content = this.host.readFile(filename); + if (!content) { + content = ""; + } + this.reload(content); + }; + ScriptVersionCache.prototype.reload = function (script) { + this.currentVersion++; + this.changes = []; + var snap = new LineIndexSnapshot(this.currentVersion, this); + for (var i = 0; i < this.versions.length; i++) { + this.versions[i] = undefined; + } + this.versions[this.currentVersionToIndex()] = snap; + snap.index = new LineIndex(); + var lm = LineIndex.linesFromText(script); + snap.index.load(lm.lines); + this.minVersion = this.currentVersion; + }; + ScriptVersionCache.prototype.getSnapshot = function () { + var snap = this.versions[this.currentVersionToIndex()]; + if (this.changes.length > 0) { + var snapIndex = snap.index; + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var change = _a[_i]; + snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); + } + snap = new LineIndexSnapshot(this.currentVersion + 1, this); + snap.index = snapIndex; + snap.changesSincePreviousVersion = this.changes; + this.currentVersion = snap.version; + this.versions[this.currentVersionToIndex()] = snap; + this.changes = []; + if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { + this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; + } + } + return snap; + }; + ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { + if (oldVersion < newVersion) { + if (oldVersion >= this.minVersion) { + var textChangeRanges = []; + for (var i = oldVersion + 1; i <= newVersion; i++) { + var snap = this.versions[this.versionToIndex(i)]; + for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { + var textChange = _a[_i]; + textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); + } + } + return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); + } + else { + return undefined; + } + } + else { + return ts.unchangedTextChangeRange; + } + }; + ScriptVersionCache.fromString = function (host, script) { + var svc = new ScriptVersionCache(); + var snap = new LineIndexSnapshot(0, svc); + svc.versions[svc.currentVersion] = snap; + svc.host = host; + snap.index = new LineIndex(); + var lm = LineIndex.linesFromText(script); + snap.index.load(lm.lines); + return svc; + }; + return ScriptVersionCache; + }()); + ScriptVersionCache.changeNumberThreshold = 8; + ScriptVersionCache.changeLengthThreshold = 256; + ScriptVersionCache.maxVersions = 8; + server.ScriptVersionCache = ScriptVersionCache; + var LineIndexSnapshot = (function () { + function LineIndexSnapshot(version, cache) { + this.version = version; + this.cache = cache; + this.changesSincePreviousVersion = []; + } + LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { + return this.index.getText(rangeStart, rangeEnd - rangeStart); + }; + LineIndexSnapshot.prototype.getLength = function () { + return this.index.root.charCount(); + }; + LineIndexSnapshot.prototype.getLineStartPositions = function () { + var starts = [-1]; + var count = 1; + var pos = 0; + this.index.every(function (ll) { + starts[count] = pos; + count++; + pos += ll.text.length; + return true; + }, 0); + return starts; + }; + LineIndexSnapshot.prototype.getLineMapper = function () { + var _this = this; + return function (line) { + return _this.index.lineNumberToInfo(line).offset; + }; + }; + LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + if (this.version <= scriptVersion) { + return ts.unchangedTextChangeRange; + } + else { + return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); + } + }; + LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { + if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) { + return this.getTextChangeRangeSinceVersion(oldSnapshot.version); + } + }; + return LineIndexSnapshot; + }()); + server.LineIndexSnapshot = LineIndexSnapshot; + var LineIndex = (function () { + function LineIndex() { + this.checkEdits = false; + } + LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { + return this.root.charOffsetToLineNumberAndPos(1, charOffset); + }; + LineIndex.prototype.lineNumberToInfo = function (lineNumber) { + var lineCount = this.root.lineCount(); + if (lineNumber <= lineCount) { + var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); + lineInfo.line = lineNumber; + return lineInfo; + } + else { + return { + line: lineNumber, + offset: this.root.charCount() + }; + } + }; + LineIndex.prototype.load = function (lines) { + if (lines.length > 0) { + var leaves = []; + for (var i = 0; i < lines.length; i++) { + leaves[i] = new LineLeaf(lines[i]); + } + this.root = LineIndex.buildTreeFromBottom(leaves); + } + else { + this.root = new LineNode(); + } + }; + LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { + this.root.walk(rangeStart, rangeLength, walkFns); + }; + LineIndex.prototype.getText = function (rangeStart, rangeLength) { + var accum = ""; + if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { + this.walk(rangeStart, rangeLength, { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); + } + }); + } + return accum; + }; + LineIndex.prototype.getLength = function () { + return this.root.charCount(); + }; + LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { + if (!rangeEnd) { + rangeEnd = this.root.charCount(); + } + var walkFns = { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + if (!f(ll, relativeStart, relativeLength)) { + this.done = true; + } + } + }; + this.walk(rangeStart, rangeEnd - rangeStart, walkFns); + return !walkFns.done; + }; + LineIndex.prototype.edit = function (pos, deleteLength, newText) { + function editFlat(source, s, dl, nt) { + if (nt === void 0) { nt = ""; } + return source.substring(0, s) + nt + source.substring(s + dl, source.length); + } + if (this.root.charCount() === 0) { + if (newText !== undefined) { + this.load(LineIndex.linesFromText(newText).lines); + return this; + } + } + else { + var checkText = void 0; + if (this.checkEdits) { + checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); + } + var walker = new EditWalker(); + if (pos >= this.root.charCount()) { + pos = this.root.charCount() - 1; + var endString = this.getText(pos, 1); + if (newText) { + newText = endString + newText; + } + else { + newText = endString; + } + deleteLength = 0; + walker.suppressTrailingText = true; + } + else if (deleteLength > 0) { + var e = pos + deleteLength; + var lineInfo = this.charOffsetToLineNumberAndPos(e); + if ((lineInfo && (lineInfo.offset === 0))) { + deleteLength += lineInfo.text.length; + if (newText) { + newText = newText + lineInfo.text; + } + else { + newText = lineInfo.text; + } + } + } + if (pos < this.root.charCount()) { + this.root.walk(pos, deleteLength, walker); + walker.insertLines(newText); + } + if (this.checkEdits) { + var updatedText = this.getText(0, this.root.charCount()); + ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); + } + return walker.lineIndex; + } + }; + LineIndex.buildTreeFromBottom = function (nodes) { + var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); + var interiorNodes = []; + var nodeIndex = 0; + for (var i = 0; i < nodeCount; i++) { + interiorNodes[i] = new LineNode(); + var charCount = 0; + var lineCount = 0; + for (var j = 0; j < lineCollectionCapacity; j++) { + if (nodeIndex < nodes.length) { + interiorNodes[i].add(nodes[nodeIndex]); + charCount += nodes[nodeIndex].charCount(); + lineCount += nodes[nodeIndex].lineCount(); + } + else { + break; + } + nodeIndex++; + } + interiorNodes[i].totalChars = charCount; + interiorNodes[i].totalLines = lineCount; + } + if (interiorNodes.length === 1) { + return interiorNodes[0]; + } + else { + return this.buildTreeFromBottom(interiorNodes); + } + }; + LineIndex.linesFromText = function (text) { + var lineStarts = ts.computeLineStarts(text); + if (lineStarts.length === 0) { + return { lines: [], lineMap: lineStarts }; + } + var lines = new Array(lineStarts.length); + var lc = lineStarts.length - 1; + for (var lmi = 0; lmi < lc; lmi++) { + lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); + } + var endText = text.substring(lineStarts[lc]); + if (endText.length > 0) { + lines[lc] = endText; + } + else { + lines.length--; + } + return { lines: lines, lineMap: lineStarts }; + }; + return LineIndex; + }()); + server.LineIndex = LineIndex; + var LineNode = (function () { + function LineNode() { + this.totalChars = 0; + this.totalLines = 0; + this.children = []; + } + LineNode.prototype.isLeaf = function () { + return false; + }; + LineNode.prototype.updateCounts = function () { + this.totalChars = 0; + this.totalLines = 0; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; + this.totalChars += child.charCount(); + this.totalLines += child.lineCount(); + } + }; + LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { + if (walkFns.pre) { + walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + if (walkFns.goSubtree) { + this.children[childIndex].walk(rangeStart, rangeLength, walkFns); + if (walkFns.post) { + walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + } + else { + walkFns.goSubtree = true; + } + return walkFns.done; + }; + LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { + if (walkFns.pre && (!walkFns.done)) { + walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); + walkFns.goSubtree = true; + } + }; + LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { + var childIndex = 0; + var child = this.children[0]; + var childCharCount = child.charCount(); + var adjustedStart = rangeStart; + while (adjustedStart >= childCharCount) { + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); + adjustedStart -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if ((adjustedStart + rangeLength) <= childCharCount) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { + return; + } + } + else { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { + return; + } + var adjustedLength = rangeLength - (childCharCount - adjustedStart); + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + while (adjustedLength > childCharCount) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { + return; + } + adjustedLength -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if (adjustedLength > 0) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { + return; + } + } + } + if (walkFns.pre) { + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var ej = childIndex + 1; ej < clen; ej++) { + this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); + } + } + } + }; + LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { + var childInfo = this.childFromCharOffset(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset, + }; + } + else if (childInfo.childIndex < this.children.length) { + if (childInfo.child.isLeaf()) { + return { + line: childInfo.lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); + } + } + else { + var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); + return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; + } + }; + LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { + var childInfo = this.childFromLineNumber(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset + }; + } + else if (childInfo.child.isLeaf()) { + return { + line: lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); + } + }; + LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { + var child; + var relativeLineNumber = lineNumber; + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + var childLineCount = child.lineCount(); + if (childLineCount >= relativeLineNumber) { + break; + } + else { + relativeLineNumber -= childLineCount; + charOffset += child.charCount(); + } + } + return { + child: child, + childIndex: i, + relativeLineNumber: relativeLineNumber, + charOffset: charOffset + }; + }; + LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { + var child; + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + if (child.charCount() > charOffset) { + break; + } + else { + charOffset -= child.charCount(); + lineNumber += child.lineCount(); + } + } + return { + child: child, + childIndex: i, + charOffset: charOffset, + lineNumber: lineNumber + }; + }; + LineNode.prototype.splitAfter = function (childIndex) { + var splitNode; + var clen = this.children.length; + childIndex++; + var endLength = childIndex; + if (childIndex < clen) { + splitNode = new LineNode(); + while (childIndex < clen) { + splitNode.add(this.children[childIndex]); + childIndex++; + } + splitNode.updateCounts(); + } + this.children.length = endLength; + return splitNode; + }; + LineNode.prototype.remove = function (child) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var i = childIndex; i < (clen - 1); i++) { + this.children[i] = this.children[i + 1]; + } + } + this.children.length--; + }; + LineNode.prototype.findChildIndex = function (child) { + var childIndex = 0; + var clen = this.children.length; + while ((this.children[childIndex] !== child) && (childIndex < clen)) + childIndex++; + return childIndex; + }; + LineNode.prototype.insertAt = function (child, nodes) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + var nodeCount = nodes.length; + if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { + this.add(nodes[0]); + this.updateCounts(); + return []; + } + else { + var shiftNode = this.splitAfter(childIndex); + var nodeIndex = 0; + childIndex++; + while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { + this.children[childIndex] = nodes[nodeIndex]; + childIndex++; + nodeIndex++; + } + var splitNodes = []; + var splitNodeCount = 0; + if (nodeIndex < nodeCount) { + splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); + splitNodes = new Array(splitNodeCount); + var splitNodeIndex = 0; + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i] = new LineNode(); + } + var splitNode = splitNodes[0]; + while (nodeIndex < nodeCount) { + splitNode.add(nodes[nodeIndex]); + nodeIndex++; + if (splitNode.children.length === lineCollectionCapacity) { + splitNodeIndex++; + splitNode = splitNodes[splitNodeIndex]; + } + } + for (var i = splitNodes.length - 1; i >= 0; i--) { + if (splitNodes[i].children.length === 0) { + splitNodes.length--; + } + } + } + if (shiftNode) { + splitNodes[splitNodes.length] = shiftNode; + } + this.updateCounts(); + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i].updateCounts(); + } + return splitNodes; + } + }; + LineNode.prototype.add = function (collection) { + this.children[this.children.length] = collection; + return (this.children.length < lineCollectionCapacity); + }; + LineNode.prototype.charCount = function () { + return this.totalChars; + }; + LineNode.prototype.lineCount = function () { + return this.totalLines; + }; + return LineNode; + }()); + server.LineNode = LineNode; + var LineLeaf = (function () { + function LineLeaf(text) { + this.text = text; + } + LineLeaf.prototype.isLeaf = function () { + return true; + }; + LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { + walkFns.leaf(rangeStart, rangeLength, this); + }; + LineLeaf.prototype.charCount = function () { + return this.text.length; + }; + LineLeaf.prototype.lineCount = function () { + return 1; + }; + return LineLeaf; + }()); + server.LineLeaf = LineLeaf; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var server; (function (server) { @@ -69910,853 +70757,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - var lineCollectionCapacity = 4; - var CharRangeSection; - (function (CharRangeSection) { - CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; - CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; - CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; - CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; - CharRangeSection[CharRangeSection["End"] = 4] = "End"; - CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); - var BaseLineIndexWalker = (function () { - function BaseLineIndexWalker() { - this.goSubtree = true; - this.done = false; - } - BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { - }; - return BaseLineIndexWalker; - }()); - var EditWalker = (function (_super) { - __extends(EditWalker, _super); - function EditWalker() { - var _this = _super.call(this) || this; - _this.lineIndex = new LineIndex(); - _this.endBranch = []; - _this.state = CharRangeSection.Entire; - _this.initialText = ""; - _this.trailingText = ""; - _this.suppressTrailingText = false; - _this.lineIndex.root = new LineNode(); - _this.startPath = [_this.lineIndex.root]; - _this.stack = [_this.lineIndex.root]; - return _this; - } - EditWalker.prototype.insertLines = function (insertedText) { - if (this.suppressTrailingText) { - this.trailingText = ""; - } - if (insertedText) { - insertedText = this.initialText + insertedText + this.trailingText; - } - else { - insertedText = this.initialText + this.trailingText; - } - var lm = LineIndex.linesFromText(insertedText); - var lines = lm.lines; - if (lines.length > 1) { - if (lines[lines.length - 1] == "") { - lines.length--; - } - } - var branchParent; - var lastZeroCount; - for (var k = this.endBranch.length - 1; k >= 0; k--) { - this.endBranch[k].updateCounts(); - if (this.endBranch[k].charCount() === 0) { - lastZeroCount = this.endBranch[k]; - if (k > 0) { - branchParent = this.endBranch[k - 1]; - } - else { - branchParent = this.branchNode; - } - } - } - if (lastZeroCount) { - branchParent.remove(lastZeroCount); - } - var insertionNode = this.startPath[this.startPath.length - 2]; - var leafNode = this.startPath[this.startPath.length - 1]; - var len = lines.length; - if (len > 0) { - leafNode.text = lines[0]; - if (len > 1) { - var insertedNodes = new Array(len - 1); - var startNode = leafNode; - for (var i = 1; i < lines.length; i++) { - insertedNodes[i - 1] = new LineLeaf(lines[i]); - } - var pathIndex = this.startPath.length - 2; - while (pathIndex >= 0) { - insertionNode = this.startPath[pathIndex]; - insertedNodes = insertionNode.insertAt(startNode, insertedNodes); - pathIndex--; - startNode = insertionNode; - } - var insertedNodesLen = insertedNodes.length; - while (insertedNodesLen > 0) { - var newRoot = new LineNode(); - newRoot.add(this.lineIndex.root); - insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); - insertedNodesLen = insertedNodes.length; - this.lineIndex.root = newRoot; - } - this.lineIndex.root.updateCounts(); - } - else { - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - } - else { - insertionNode.remove(leafNode); - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - return this.lineIndex; - }; - EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { - if (lineCollection === this.lineCollectionAtBranch) { - this.state = CharRangeSection.End; - } - this.stack.length--; - return undefined; - }; - EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { - var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { - this.state = CharRangeSection.Start; - this.branchNode = currentNode; - this.lineCollectionAtBranch = lineCollection; - } - var child; - function fresh(node) { - if (node.isLeaf()) { - return new LineLeaf(""); - } - else - return new LineNode(); - } - switch (nodeType) { - case CharRangeSection.PreStart: - this.goSubtree = false; - if (this.state !== CharRangeSection.End) { - currentNode.add(lineCollection); - } - break; - case CharRangeSection.Start: - if (this.state === CharRangeSection.End) { - this.goSubtree = false; - } - else { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - break; - case CharRangeSection.Entire: - if (this.state !== CharRangeSection.End) { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.Mid: - this.goSubtree = false; - break; - case CharRangeSection.End: - if (this.state !== CharRangeSection.End) { - this.goSubtree = false; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.PostEnd: - this.goSubtree = false; - if (this.state !== CharRangeSection.Start) { - currentNode.add(lineCollection); - } - break; - } - if (this.goSubtree) { - this.stack[this.stack.length] = child; - } - return lineCollection; - }; - EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === CharRangeSection.Start) { - this.initialText = ll.text.substring(0, relativeStart); - } - else if (this.state === CharRangeSection.Entire) { - this.initialText = ll.text.substring(0, relativeStart); - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - else { - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - }; - return EditWalker; - }(BaseLineIndexWalker)); - var TextChange = (function () { - function TextChange(pos, deleteLen, insertedText) { - this.pos = pos; - this.deleteLen = deleteLen; - this.insertedText = insertedText; - } - TextChange.prototype.getTextChangeRange = function () { - return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); - }; - return TextChange; - }()); - server.TextChange = TextChange; - var ScriptVersionCache = (function () { - function ScriptVersionCache() { - this.changes = []; - this.versions = new Array(ScriptVersionCache.maxVersions); - this.minVersion = 0; - this.currentVersion = 0; - } - ScriptVersionCache.prototype.versionToIndex = function (version) { - if (version < this.minVersion || version > this.currentVersion) { - return undefined; - } - return version % ScriptVersionCache.maxVersions; - }; - ScriptVersionCache.prototype.currentVersionToIndex = function () { - return this.currentVersion % ScriptVersionCache.maxVersions; - }; - ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { - this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); - if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || - (deleteLen > ScriptVersionCache.changeLengthThreshold) || - (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { - this.getSnapshot(); - } - }; - ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersionToIndex()]; - }; - ScriptVersionCache.prototype.latestVersion = function () { - if (this.changes.length > 0) { - this.getSnapshot(); - } - return this.currentVersion; - }; - ScriptVersionCache.prototype.reloadFromFile = function (filename) { - var content = this.host.readFile(filename); - if (!content) { - content = ""; - } - this.reload(content); - }; - ScriptVersionCache.prototype.reload = function (script) { - this.currentVersion++; - this.changes = []; - var snap = new LineIndexSnapshot(this.currentVersion, this); - for (var i = 0; i < this.versions.length; i++) { - this.versions[i] = undefined; - } - this.versions[this.currentVersionToIndex()] = snap; - snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); - snap.index.load(lm.lines); - this.minVersion = this.currentVersion; - }; - ScriptVersionCache.prototype.getSnapshot = function () { - var snap = this.versions[this.currentVersionToIndex()]; - if (this.changes.length > 0) { - var snapIndex = snap.index; - for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { - var change = _a[_i]; - snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); - } - snap = new LineIndexSnapshot(this.currentVersion + 1, this); - snap.index = snapIndex; - snap.changesSincePreviousVersion = this.changes; - this.currentVersion = snap.version; - this.versions[this.currentVersionToIndex()] = snap; - this.changes = []; - if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { - this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; - } - } - return snap; - }; - ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { - if (oldVersion < newVersion) { - if (oldVersion >= this.minVersion) { - var textChangeRanges = []; - for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[this.versionToIndex(i)]; - for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { - var textChange = _a[_i]; - textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); - } - } - return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); - } - else { - return undefined; - } - } - else { - return ts.unchangedTextChangeRange; - } - }; - ScriptVersionCache.fromString = function (host, script) { - var svc = new ScriptVersionCache(); - var snap = new LineIndexSnapshot(0, svc); - svc.versions[svc.currentVersion] = snap; - svc.host = host; - snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); - snap.index.load(lm.lines); - return svc; - }; - return ScriptVersionCache; - }()); - ScriptVersionCache.changeNumberThreshold = 8; - ScriptVersionCache.changeLengthThreshold = 256; - ScriptVersionCache.maxVersions = 8; - server.ScriptVersionCache = ScriptVersionCache; - var LineIndexSnapshot = (function () { - function LineIndexSnapshot(version, cache) { - this.version = version; - this.cache = cache; - this.changesSincePreviousVersion = []; - } - LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { - return this.index.getText(rangeStart, rangeEnd - rangeStart); - }; - LineIndexSnapshot.prototype.getLength = function () { - return this.index.root.charCount(); - }; - LineIndexSnapshot.prototype.getLineStartPositions = function () { - var starts = [-1]; - var count = 1; - var pos = 0; - this.index.every(function (ll) { - starts[count] = pos; - count++; - pos += ll.text.length; - return true; - }, 0); - return starts; - }; - LineIndexSnapshot.prototype.getLineMapper = function () { - var _this = this; - return function (line) { - return _this.index.lineNumberToInfo(line).offset; - }; - }; - LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - if (this.version <= scriptVersion) { - return ts.unchangedTextChangeRange; - } - else { - return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); - } - }; - LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { - if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) { - return this.getTextChangeRangeSinceVersion(oldSnapshot.version); - } - }; - return LineIndexSnapshot; - }()); - server.LineIndexSnapshot = LineIndexSnapshot; - var LineIndex = (function () { - function LineIndex() { - this.checkEdits = false; - } - LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { - return this.root.charOffsetToLineNumberAndPos(1, charOffset); - }; - LineIndex.prototype.lineNumberToInfo = function (lineNumber) { - var lineCount = this.root.lineCount(); - if (lineNumber <= lineCount) { - var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); - lineInfo.line = lineNumber; - return lineInfo; - } - else { - return { - line: lineNumber, - offset: this.root.charCount() - }; - } - }; - LineIndex.prototype.load = function (lines) { - if (lines.length > 0) { - var leaves = []; - for (var i = 0; i < lines.length; i++) { - leaves[i] = new LineLeaf(lines[i]); - } - this.root = LineIndex.buildTreeFromBottom(leaves); - } - else { - this.root = new LineNode(); - } - }; - LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { - this.root.walk(rangeStart, rangeLength, walkFns); - }; - LineIndex.prototype.getText = function (rangeStart, rangeLength) { - var accum = ""; - if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { - this.walk(rangeStart, rangeLength, { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); - } - }); - } - return accum; - }; - LineIndex.prototype.getLength = function () { - return this.root.charCount(); - }; - LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { - if (!rangeEnd) { - rangeEnd = this.root.charCount(); - } - var walkFns = { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - if (!f(ll, relativeStart, relativeLength)) { - this.done = true; - } - } - }; - this.walk(rangeStart, rangeEnd - rangeStart, walkFns); - return !walkFns.done; - }; - LineIndex.prototype.edit = function (pos, deleteLength, newText) { - function editFlat(source, s, dl, nt) { - if (nt === void 0) { nt = ""; } - return source.substring(0, s) + nt + source.substring(s + dl, source.length); - } - if (this.root.charCount() === 0) { - if (newText !== undefined) { - this.load(LineIndex.linesFromText(newText).lines); - return this; - } - } - else { - var checkText = void 0; - if (this.checkEdits) { - checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); - } - var walker = new EditWalker(); - if (pos >= this.root.charCount()) { - pos = this.root.charCount() - 1; - var endString = this.getText(pos, 1); - if (newText) { - newText = endString + newText; - } - else { - newText = endString; - } - deleteLength = 0; - walker.suppressTrailingText = true; - } - else if (deleteLength > 0) { - var e = pos + deleteLength; - var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.offset === 0))) { - deleteLength += lineInfo.text.length; - if (newText) { - newText = newText + lineInfo.text; - } - else { - newText = lineInfo.text; - } - } - } - if (pos < this.root.charCount()) { - this.root.walk(pos, deleteLength, walker); - walker.insertLines(newText); - } - if (this.checkEdits) { - var updatedText = this.getText(0, this.root.charCount()); - ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); - } - return walker.lineIndex; - } - }; - LineIndex.buildTreeFromBottom = function (nodes) { - var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); - var interiorNodes = []; - var nodeIndex = 0; - for (var i = 0; i < nodeCount; i++) { - interiorNodes[i] = new LineNode(); - var charCount = 0; - var lineCount = 0; - for (var j = 0; j < lineCollectionCapacity; j++) { - if (nodeIndex < nodes.length) { - interiorNodes[i].add(nodes[nodeIndex]); - charCount += nodes[nodeIndex].charCount(); - lineCount += nodes[nodeIndex].lineCount(); - } - else { - break; - } - nodeIndex++; - } - interiorNodes[i].totalChars = charCount; - interiorNodes[i].totalLines = lineCount; - } - if (interiorNodes.length === 1) { - return interiorNodes[0]; - } - else { - return this.buildTreeFromBottom(interiorNodes); - } - }; - LineIndex.linesFromText = function (text) { - var lineStarts = ts.computeLineStarts(text); - if (lineStarts.length === 0) { - return { lines: [], lineMap: lineStarts }; - } - var lines = new Array(lineStarts.length); - var lc = lineStarts.length - 1; - for (var lmi = 0; lmi < lc; lmi++) { - lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); - } - var endText = text.substring(lineStarts[lc]); - if (endText.length > 0) { - lines[lc] = endText; - } - else { - lines.length--; - } - return { lines: lines, lineMap: lineStarts }; - }; - return LineIndex; - }()); - server.LineIndex = LineIndex; - var LineNode = (function () { - function LineNode() { - this.totalChars = 0; - this.totalLines = 0; - this.children = []; - } - LineNode.prototype.isLeaf = function () { - return false; - }; - LineNode.prototype.updateCounts = function () { - this.totalChars = 0; - this.totalLines = 0; - for (var _i = 0, _a = this.children; _i < _a.length; _i++) { - var child = _a[_i]; - this.totalChars += child.charCount(); - this.totalLines += child.lineCount(); - } - }; - LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { - if (walkFns.pre) { - walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - if (walkFns.goSubtree) { - this.children[childIndex].walk(rangeStart, rangeLength, walkFns); - if (walkFns.post) { - walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - } - else { - walkFns.goSubtree = true; - } - return walkFns.done; - }; - LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { - if (walkFns.pre && (!walkFns.done)) { - walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); - walkFns.goSubtree = true; - } - }; - LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { - var childIndex = 0; - var child = this.children[0]; - var childCharCount = child.charCount(); - var adjustedStart = rangeStart; - while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); - adjustedStart -= childCharCount; - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - } - if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { - return; - } - } - else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { - return; - } - var adjustedLength = rangeLength - (childCharCount - adjustedStart); - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { - return; - } - adjustedLength -= childCharCount; - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - } - if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { - return; - } - } - } - if (walkFns.pre) { - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); - } - } - } - }; - LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { - var childInfo = this.childFromCharOffset(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset, - }; - } - else if (childInfo.childIndex < this.children.length) { - if (childInfo.child.isLeaf()) { - return { - line: childInfo.lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); - } - } - else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; - } - }; - LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { - var childInfo = this.childFromLineNumber(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset - }; - } - else if (childInfo.child.isLeaf()) { - return { - line: lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); - } - }; - LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { - var child; - var relativeLineNumber = lineNumber; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - var childLineCount = child.lineCount(); - if (childLineCount >= relativeLineNumber) { - break; - } - else { - relativeLineNumber -= childLineCount; - charOffset += child.charCount(); - } - } - return { - child: child, - childIndex: i, - relativeLineNumber: relativeLineNumber, - charOffset: charOffset - }; - }; - LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { - var child; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - if (child.charCount() > charOffset) { - break; - } - else { - charOffset -= child.charCount(); - lineNumber += child.lineCount(); - } - } - return { - child: child, - childIndex: i, - charOffset: charOffset, - lineNumber: lineNumber - }; - }; - LineNode.prototype.splitAfter = function (childIndex) { - var splitNode; - var clen = this.children.length; - childIndex++; - var endLength = childIndex; - if (childIndex < clen) { - splitNode = new LineNode(); - while (childIndex < clen) { - splitNode.add(this.children[childIndex]); - childIndex++; - } - splitNode.updateCounts(); - } - this.children.length = endLength; - return splitNode; - }; - LineNode.prototype.remove = function (child) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var i = childIndex; i < (clen - 1); i++) { - this.children[i] = this.children[i + 1]; - } - } - this.children.length--; - }; - LineNode.prototype.findChildIndex = function (child) { - var childIndex = 0; - var clen = this.children.length; - while ((this.children[childIndex] !== child) && (childIndex < clen)) - childIndex++; - return childIndex; - }; - LineNode.prototype.insertAt = function (child, nodes) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - var nodeCount = nodes.length; - if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { - this.add(nodes[0]); - this.updateCounts(); - return []; - } - else { - var shiftNode = this.splitAfter(childIndex); - var nodeIndex = 0; - childIndex++; - while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { - this.children[childIndex] = nodes[nodeIndex]; - childIndex++; - nodeIndex++; - } - var splitNodes = []; - var splitNodeCount = 0; - if (nodeIndex < nodeCount) { - splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); - splitNodes = new Array(splitNodeCount); - var splitNodeIndex = 0; - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i] = new LineNode(); - } - var splitNode = splitNodes[0]; - while (nodeIndex < nodeCount) { - splitNode.add(nodes[nodeIndex]); - nodeIndex++; - if (splitNode.children.length === lineCollectionCapacity) { - splitNodeIndex++; - splitNode = splitNodes[splitNodeIndex]; - } - } - for (var i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length === 0) { - splitNodes.length--; - } - } - } - if (shiftNode) { - splitNodes[splitNodes.length] = shiftNode; - } - this.updateCounts(); - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i].updateCounts(); - } - return splitNodes; - } - }; - LineNode.prototype.add = function (collection) { - this.children[this.children.length] = collection; - return (this.children.length < lineCollectionCapacity); - }; - LineNode.prototype.charCount = function () { - return this.totalChars; - }; - LineNode.prototype.lineCount = function () { - return this.totalLines; - }; - return LineNode; - }()); - server.LineNode = LineNode; - var LineLeaf = (function () { - function LineLeaf(text) { - this.text = text; - } - LineLeaf.prototype.isLeaf = function () { - return true; - }; - LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { - walkFns.leaf(rangeStart, rangeLength, this); - }; - LineLeaf.prototype.charCount = function () { - return this.text.length; - }; - LineLeaf.prototype.lineCount = function () { - return 1; - }; - return LineLeaf; - }()); - server.LineLeaf = LineLeaf; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var server; (function (server) { diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 25ed333b299..232684eedc6 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1,875 +1,18 @@ -/// -declare namespace ts.server.protocol { - namespace CommandTypes { - type Brace = "brace"; - type BraceFull = "brace-full"; - type BraceCompletion = "braceCompletion"; - type Change = "change"; - type Close = "close"; - type Completions = "completions"; - type CompletionsFull = "completions-full"; - type CompletionDetails = "completionEntryDetails"; - type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - type Configure = "configure"; - type Definition = "definition"; - type DefinitionFull = "definition-full"; - type Implementation = "implementation"; - type ImplementationFull = "implementation-full"; - type Exit = "exit"; - type Format = "format"; - type Formatonkey = "formatonkey"; - type FormatFull = "format-full"; - type FormatonkeyFull = "formatonkey-full"; - type FormatRangeFull = "formatRange-full"; - type Geterr = "geterr"; - type GeterrForProject = "geterrForProject"; - type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - type NavBar = "navbar"; - type NavBarFull = "navbar-full"; - type Navto = "navto"; - type NavtoFull = "navto-full"; - type NavTree = "navtree"; - type NavTreeFull = "navtree-full"; - type Occurrences = "occurrences"; - type DocumentHighlights = "documentHighlights"; - type DocumentHighlightsFull = "documentHighlights-full"; - type Open = "open"; - type Quickinfo = "quickinfo"; - type QuickinfoFull = "quickinfo-full"; - type References = "references"; - type ReferencesFull = "references-full"; - type Reload = "reload"; - type Rename = "rename"; - type RenameInfoFull = "rename-full"; - type RenameLocationsFull = "renameLocations-full"; - type Saveto = "saveto"; - type SignatureHelp = "signatureHelp"; - type SignatureHelpFull = "signatureHelp-full"; - type TypeDefinition = "typeDefinition"; - type ProjectInfo = "projectInfo"; - type ReloadProjects = "reloadProjects"; - type Unknown = "unknown"; - type OpenExternalProject = "openExternalProject"; - type OpenExternalProjects = "openExternalProjects"; - type CloseExternalProject = "closeExternalProject"; - type SynchronizeProjectList = "synchronizeProjectList"; - type ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - type Cleanup = "cleanup"; - type OutliningSpans = "outliningSpans"; - type TodoComments = "todoComments"; - type Indentation = "indentation"; - type DocCommentTemplate = "docCommentTemplate"; - type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - type NameOrDottedNameSpan = "nameOrDottedNameSpan"; - type BreakpointStatement = "breakpointStatement"; - type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - type GetCodeFixes = "getCodeFixes"; - type GetCodeFixesFull = "getCodeFixes-full"; - type GetSupportedCodeFixes = "getSupportedCodeFixes"; - } - interface Message { - seq: number; - type: "request" | "response" | "event"; - } - interface Request extends Message { - command: string; - arguments?: any; - } - interface ReloadProjectsRequest extends Message { - command: CommandTypes.ReloadProjects; - } - interface Event extends Message { - event: string; - body?: any; - } - interface Response extends Message { - request_seq: number; - success: boolean; - command: string; - message?: string; - body?: any; - } - interface FileRequestArgs { - file: string; - projectFileName?: string; - } - interface DocCommentTemplateRequest extends FileLocationRequest { - command: CommandTypes.DocCommentTemplate; - } - interface DocCommandTemplateResponse extends Response { - body?: TextInsertion; - } - interface TodoCommentRequest extends FileRequest { - command: CommandTypes.TodoComments; - arguments: TodoCommentRequestArgs; - } - interface TodoCommentRequestArgs extends FileRequestArgs { - descriptors: TodoCommentDescriptor[]; - } - interface TodoCommentsResponse extends Response { - body?: TodoComment[]; - } - interface OutliningSpansRequest extends FileRequest { - command: CommandTypes.OutliningSpans; - } - interface OutliningSpansResponse extends Response { - body?: OutliningSpan[]; - } - interface IndentationRequest extends FileLocationRequest { - command: CommandTypes.Indentation; - arguments: IndentationRequestArgs; - } - interface IndentationResponse extends Response { - body?: IndentationResult; - } - interface IndentationResult { - position: number; - indentation: number; - } - interface IndentationRequestArgs extends FileLocationRequestArgs { - options?: EditorSettings; - } - interface ProjectInfoRequestArgs extends FileRequestArgs { - needFileNameList: boolean; - } - interface ProjectInfoRequest extends Request { - command: CommandTypes.ProjectInfo; - arguments: ProjectInfoRequestArgs; - } - interface CompilerOptionsDiagnosticsRequest extends Request { - arguments: CompilerOptionsDiagnosticsRequestArgs; - } - interface CompilerOptionsDiagnosticsRequestArgs { - projectFileName: string; - } - interface ProjectInfo { - configFileName: string; - fileNames?: string[]; - languageServiceDisabled?: boolean; - } - interface DiagnosticWithLinePosition { - message: string; - start: number; - length: number; - startLocation: Location; - endLocation: Location; - category: string; - code: number; - } - interface ProjectInfoResponse extends Response { - body?: ProjectInfo; - } - interface FileRequest extends Request { - arguments: FileRequestArgs; - } - interface FileLocationRequestArgs extends FileRequestArgs { - line: number; - offset: number; - position?: number; - } - interface CodeFixRequest extends Request { - command: CommandTypes.GetCodeFixes; - arguments: CodeFixRequestArgs; - } - interface CodeFixRequestArgs extends FileRequestArgs { - startLine: number; - startOffset: number; - startPosition?: number; - endLine: number; - endOffset: number; - endPosition?: number; - errorCodes?: number[]; - } - interface GetCodeFixesResponse extends Response { - body?: CodeAction[]; - } - interface FileLocationRequest extends FileRequest { - arguments: FileLocationRequestArgs; - } - interface GetSupportedCodeFixesRequest extends Request { - command: CommandTypes.GetSupportedCodeFixes; - } - interface GetSupportedCodeFixesResponse extends Response { - body?: string[]; - } - interface EncodedSemanticClassificationsRequest extends FileRequest { - arguments: EncodedSemanticClassificationsRequestArgs; - } - interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { - start: number; - length: number; - } - interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { - filesToSearch: string[]; - } - interface DefinitionRequest extends FileLocationRequest { - command: CommandTypes.Definition; - } - interface TypeDefinitionRequest extends FileLocationRequest { - command: CommandTypes.TypeDefinition; - } - interface ImplementationRequest extends FileLocationRequest { - command: CommandTypes.Implementation; - } - interface Location { - line: number; - offset: number; - } - interface TextSpan { - start: Location; - end: Location; - } - interface FileSpan extends TextSpan { - file: string; - } - interface DefinitionResponse extends Response { - body?: FileSpan[]; - } - interface TypeDefinitionResponse extends Response { - body?: FileSpan[]; - } - interface ImplementationResponse extends Response { - body?: FileSpan[]; - } - interface BraceCompletionRequest extends FileLocationRequest { - command: CommandTypes.BraceCompletion; - arguments: BraceCompletionRequestArgs; - } - interface BraceCompletionRequestArgs extends FileLocationRequestArgs { - openingBrace: string; - } - interface OccurrencesRequest extends FileLocationRequest { - command: CommandTypes.Occurrences; - } - interface OccurrencesResponseItem extends FileSpan { - isWriteAccess: boolean; - } - interface OccurrencesResponse extends Response { - body?: OccurrencesResponseItem[]; - } - interface DocumentHighlightsRequest extends FileLocationRequest { - command: CommandTypes.DocumentHighlights; - arguments: DocumentHighlightsRequestArgs; - } - interface HighlightSpan extends TextSpan { - kind: string; - } - interface DocumentHighlightsItem { - file: string; - highlightSpans: HighlightSpan[]; - } - interface DocumentHighlightsResponse extends Response { - body?: DocumentHighlightsItem[]; - } - interface ReferencesRequest extends FileLocationRequest { - command: CommandTypes.References; - } - interface ReferencesResponseItem extends FileSpan { - lineText: string; - isWriteAccess: boolean; - isDefinition: boolean; - } - interface ReferencesResponseBody { - refs: ReferencesResponseItem[]; - symbolName: string; - symbolStartOffset: number; - symbolDisplayString: string; - } - interface ReferencesResponse extends Response { - body?: ReferencesResponseBody; - } - interface RenameRequestArgs extends FileLocationRequestArgs { - findInComments?: boolean; - findInStrings?: boolean; - } - interface RenameRequest extends FileLocationRequest { - command: CommandTypes.Rename; - arguments: RenameRequestArgs; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage?: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - } - interface SpanGroup { - file: string; - locs: TextSpan[]; - } - interface RenameResponseBody { - info: RenameInfo; - locs: SpanGroup[]; - } - interface RenameResponse extends Response { - body?: RenameResponseBody; - } - interface ExternalFile { - fileName: string; - scriptKind?: ScriptKindName | ts.ScriptKind; - hasMixedContent?: boolean; - content?: string; - } - interface ExternalProject { - projectFileName: string; - rootFiles: ExternalFile[]; - options: ExternalProjectCompilerOptions; - typingOptions?: TypeAcquisition; - typeAcquisition?: TypeAcquisition; - } - interface CompileOnSaveMixin { - compileOnSave?: boolean; - } - type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; - interface ProjectVersionInfo { - projectName: string; - isInferred: boolean; - version: number; - options: ts.CompilerOptions; - languageServiceDisabled: boolean; - } - interface ProjectChanges { - added: string[]; - removed: string[]; - updated: string[]; - } - interface ProjectFiles { - info?: ProjectVersionInfo; - files?: string[]; - changes?: ProjectChanges; - } - interface ProjectFilesWithDiagnostics extends ProjectFiles { - projectErrors: DiagnosticWithLinePosition[]; - } - interface ChangedOpenFile { - fileName: string; - changes: ts.TextChange[]; - } - interface ConfigureRequestArguments { - hostInfo?: string; - file?: string; - formatOptions?: FormatCodeSettings; - extraFileExtensions?: FileExtensionInfo[]; - } - interface ConfigureRequest extends Request { - command: CommandTypes.Configure; - arguments: ConfigureRequestArguments; - } - interface ConfigureResponse extends Response { - } - interface OpenRequestArgs extends FileRequestArgs { - fileContent?: string; - scriptKindName?: ScriptKindName; - } - type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; - interface OpenRequest extends Request { - command: CommandTypes.Open; - arguments: OpenRequestArgs; - } - interface OpenExternalProjectRequest extends Request { - command: CommandTypes.OpenExternalProject; - arguments: OpenExternalProjectArgs; - } - type OpenExternalProjectArgs = ExternalProject; - interface OpenExternalProjectsRequest extends Request { - command: CommandTypes.OpenExternalProjects; - arguments: OpenExternalProjectsArgs; - } - interface OpenExternalProjectsArgs { - projects: ExternalProject[]; - } - interface OpenExternalProjectResponse extends Response { - } - interface OpenExternalProjectsResponse extends Response { - } - interface CloseExternalProjectRequest extends Request { - command: CommandTypes.CloseExternalProject; - arguments: CloseExternalProjectRequestArgs; - } - interface CloseExternalProjectRequestArgs { - projectFileName: string; - } - interface CloseExternalProjectResponse extends Response { - } - interface SynchronizeProjectListRequest extends Request { - arguments: SynchronizeProjectListRequestArgs; - } - interface SynchronizeProjectListRequestArgs { - knownProjects: protocol.ProjectVersionInfo[]; - } - interface ApplyChangedToOpenFilesRequest extends Request { - arguments: ApplyChangedToOpenFilesRequestArgs; - } - interface ApplyChangedToOpenFilesRequestArgs { - openFiles?: ExternalFile[]; - changedFiles?: ChangedOpenFile[]; - closedFiles?: string[]; - } - interface SetCompilerOptionsForInferredProjectsRequest extends Request { - command: CommandTypes.CompilerOptionsForInferredProjects; - arguments: SetCompilerOptionsForInferredProjectsArgs; - } - interface SetCompilerOptionsForInferredProjectsArgs { - options: ExternalProjectCompilerOptions; - } - interface SetCompilerOptionsForInferredProjectsResponse extends Response { - } - interface ExitRequest extends Request { - command: CommandTypes.Exit; - } - interface CloseRequest extends FileRequest { - command: CommandTypes.Close; - } - interface CompileOnSaveAffectedFileListRequest extends FileRequest { - command: CommandTypes.CompileOnSaveAffectedFileList; - } - interface CompileOnSaveAffectedFileListSingleProject { - projectFileName: string; - fileNames: string[]; - } - interface CompileOnSaveAffectedFileListResponse extends Response { - body: CompileOnSaveAffectedFileListSingleProject[]; - } - interface CompileOnSaveEmitFileRequest extends FileRequest { - command: CommandTypes.CompileOnSaveEmitFile; - arguments: CompileOnSaveEmitFileRequestArgs; - } - interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { - forced?: boolean; - } - interface QuickInfoRequest extends FileLocationRequest { - command: CommandTypes.Quickinfo; - } - interface QuickInfoResponseBody { - kind: string; - kindModifiers: string; - start: Location; - end: Location; - displayString: string; - documentation: string; - } - interface QuickInfoResponse extends Response { - body?: QuickInfoResponseBody; - } - interface FormatRequestArgs extends FileLocationRequestArgs { - endLine: number; - endOffset: number; - endPosition?: number; - options?: FormatCodeSettings; - } - interface FormatRequest extends FileLocationRequest { - command: CommandTypes.Format; - arguments: FormatRequestArgs; - } - interface CodeEdit { - start: Location; - end: Location; - newText: string; - } - interface FileCodeEdits { - fileName: string; - textChanges: CodeEdit[]; - } - interface CodeFixResponse extends Response { - body?: CodeAction[]; - } - interface CodeAction { - description: string; - changes: FileCodeEdits[]; - } - interface FormatResponse extends Response { - body?: CodeEdit[]; - } - interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { - key: string; - options?: FormatCodeSettings; - } - interface FormatOnKeyRequest extends FileLocationRequest { - command: CommandTypes.Formatonkey; - arguments: FormatOnKeyRequestArgs; - } - interface CompletionsRequestArgs extends FileLocationRequestArgs { - prefix?: string; - } - interface CompletionsRequest extends FileLocationRequest { - command: CommandTypes.Completions; - arguments: CompletionsRequestArgs; - } - interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { - entryNames: string[]; - } - interface CompletionDetailsRequest extends FileLocationRequest { - command: CommandTypes.CompletionDetails; - arguments: CompletionDetailsRequestArgs; - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - replacementSpan?: TextSpan; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface CompletionsResponse extends Response { - body?: CompletionEntry[]; - } - interface CompletionDetailsResponse extends Response { - body?: CompletionEntryDetails[]; - } - interface SignatureHelpParameter { - name: string; - documentation: SymbolDisplayPart[]; - displayParts: SymbolDisplayPart[]; - isOptional: boolean; - } - interface SignatureHelpItem { - isVariadic: boolean; - prefixDisplayParts: SymbolDisplayPart[]; - suffixDisplayParts: SymbolDisplayPart[]; - separatorDisplayParts: SymbolDisplayPart[]; - parameters: SignatureHelpParameter[]; - documentation: SymbolDisplayPart[]; - } - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface SignatureHelpRequestArgs extends FileLocationRequestArgs { - } - interface SignatureHelpRequest extends FileLocationRequest { - command: CommandTypes.SignatureHelp; - arguments: SignatureHelpRequestArgs; - } - interface SignatureHelpResponse extends Response { - body?: SignatureHelpItems; - } - interface SemanticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SemanticDiagnosticsSync; - arguments: SemanticDiagnosticsSyncRequestArgs; - } - interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SemanticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface SyntacticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SyntacticDiagnosticsSync; - arguments: SyntacticDiagnosticsSyncRequestArgs; - } - interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SyntacticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface GeterrForProjectRequestArgs { - file: string; - delay: number; - } - interface GeterrForProjectRequest extends Request { - command: CommandTypes.GeterrForProject; - arguments: GeterrForProjectRequestArgs; - } - interface GeterrRequestArgs { - files: string[]; - delay: number; - } - interface GeterrRequest extends Request { - command: CommandTypes.Geterr; - arguments: GeterrRequestArgs; - } - interface Diagnostic { - start: Location; - end: Location; - text: string; - code?: number; - } - interface DiagnosticEventBody { - file: string; - diagnostics: Diagnostic[]; - } - interface DiagnosticEvent extends Event { - body?: DiagnosticEventBody; - } - interface ConfigFileDiagnosticEventBody { - triggerFile: string; - configFile: string; - diagnostics: Diagnostic[]; - } - interface ConfigFileDiagnosticEvent extends Event { - body?: ConfigFileDiagnosticEventBody; - event: "configFileDiag"; - } - type ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; - interface ProjectLanguageServiceStateEvent extends Event { - event: ProjectLanguageServiceStateEventName; - body?: ProjectLanguageServiceStateEventBody; - } - interface ProjectLanguageServiceStateEventBody { - projectName: string; - languageServiceEnabled: boolean; - } - interface ReloadRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface ReloadRequest extends FileRequest { - command: CommandTypes.Reload; - arguments: ReloadRequestArgs; - } - interface ReloadResponse extends Response { - } - interface SavetoRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface SavetoRequest extends FileRequest { - command: CommandTypes.Saveto; - arguments: SavetoRequestArgs; - } - interface NavtoRequestArgs extends FileRequestArgs { - searchValue: string; - maxResultCount?: number; - currentFileOnly?: boolean; - projectFileName?: string; - } - interface NavtoRequest extends FileRequest { - command: CommandTypes.Navto; - arguments: NavtoRequestArgs; - } - interface NavtoItem { - name: string; - kind: string; - matchKind?: string; - isCaseSensitive?: boolean; - kindModifiers?: string; - file: string; - start: Location; - end: Location; - containerName?: string; - containerKind?: string; - } - interface NavtoResponse extends Response { - body?: NavtoItem[]; - } - interface ChangeRequestArgs extends FormatRequestArgs { - insertString?: string; - } - interface ChangeRequest extends FileLocationRequest { - command: CommandTypes.Change; - arguments: ChangeRequestArgs; - } - interface BraceResponse extends Response { - body?: TextSpan[]; - } - interface BraceRequest extends FileLocationRequest { - command: CommandTypes.Brace; - } - interface NavBarRequest extends FileRequest { - command: CommandTypes.NavBar; - } - interface NavTreeRequest extends FileRequest { - command: CommandTypes.NavTree; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers?: string; - spans: TextSpan[]; - childItems?: NavigationBarItem[]; - indent: number; - } - interface NavigationTree { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems?: NavigationTree[]; - } - type TelemetryEventName = "telemetry"; - interface TelemetryEvent extends Event { - event: TelemetryEventName; - body: TelemetryEventBody; - } - interface TelemetryEventBody { - telemetryEventName: string; - payload: any; - } - type TypingsInstalledTelemetryEventName = "typingsInstalled"; - interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { - telemetryEventName: TypingsInstalledTelemetryEventName; - payload: TypingsInstalledTelemetryEventPayload; - } - interface TypingsInstalledTelemetryEventPayload { - installedPackages: string; - installSuccess: boolean; - typingsInstallerVersion: string; - } - type BeginInstallTypesEventName = "beginInstallTypes"; - type EndInstallTypesEventName = "endInstallTypes"; - interface BeginInstallTypesEvent extends Event { - event: BeginInstallTypesEventName; - body: BeginInstallTypesEventBody; - } - interface EndInstallTypesEvent extends Event { - event: EndInstallTypesEventName; - body: EndInstallTypesEventBody; - } - interface InstallTypesEventBody { - eventId: number; - packages: ReadonlyArray; - } - interface BeginInstallTypesEventBody extends InstallTypesEventBody { - } - interface EndInstallTypesEventBody extends InstallTypesEventBody { - success: boolean; - } - interface NavBarResponse extends Response { - body?: NavigationBarItem[]; - } - interface NavTreeResponse extends Response { - body?: NavigationTree; - } - namespace IndentStyle { - type None = "None"; - type Block = "Block"; - type Smart = "Smart"; - } - type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; - interface EditorSettings { - baseIndentSize?: number; - indentSize?: number; - tabSize?: number; - newLineCharacter?: string; - convertTabsToSpaces?: boolean; - indentStyle?: IndentStyle | ts.IndentStyle; - } - interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterConstructor?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - insertSpaceBeforeFunctionParenthesis?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - } - interface CompilerOptions { - allowJs?: boolean; - allowSyntheticDefaultImports?: boolean; - allowUnreachableCode?: boolean; - allowUnusedLabels?: boolean; - baseUrl?: string; - charset?: string; - declaration?: boolean; - declarationDir?: string; - disableSizeLimit?: boolean; - emitBOM?: boolean; - emitDecoratorMetadata?: boolean; - experimentalDecorators?: boolean; - forceConsistentCasingInFileNames?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - isolatedModules?: boolean; - jsx?: JsxEmit | ts.JsxEmit; - lib?: string[]; - locale?: string; - mapRoot?: string; - maxNodeModuleJsDepth?: number; - module?: ModuleKind | ts.ModuleKind; - moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; - newLine?: NewLineKind | ts.NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noFallthroughCasesInSwitch?: boolean; - noImplicitAny?: boolean; - noImplicitReturns?: boolean; - noImplicitThis?: boolean; - noUnusedLocals?: boolean; - noUnusedParameters?: boolean; - noImplicitUseStrict?: boolean; - noLib?: boolean; - noResolve?: boolean; - out?: string; - outDir?: string; - outFile?: string; - paths?: MapLike; - preserveConstEnums?: boolean; - project?: string; - reactNamespace?: string; - removeComments?: boolean; - rootDir?: string; - rootDirs?: string[]; - skipLibCheck?: boolean; - skipDefaultLibCheck?: boolean; - sourceMap?: boolean; - sourceRoot?: string; - strictNullChecks?: boolean; - suppressExcessPropertyErrors?: boolean; - suppressImplicitAnyIndexErrors?: boolean; - target?: ScriptTarget | ts.ScriptTarget; - traceResolution?: boolean; - types?: string[]; - typeRoots?: string[]; - [option: string]: CompilerOptionsValue | undefined; - } - namespace JsxEmit { - type None = "None"; - type Preserve = "Preserve"; - type React = "React"; - } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; - namespace ModuleKind { - type None = "None"; - type CommonJS = "CommonJS"; - type AMD = "AMD"; - type UMD = "UMD"; - type System = "System"; - type ES6 = "ES6"; - type ES2015 = "ES2015"; - } - type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; - namespace ModuleResolutionKind { - type Classic = "Classic"; - type Node = "Node"; - } - type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; - namespace NewLineKind { - type Crlf = "Crlf"; - type Lf = "Lf"; - } - type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; - namespace ScriptTarget { - type ES3 = "ES3"; - type ES5 = "ES5"; - type ES6 = "ES6"; - type ES2015 = "ES2015"; - } - type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; -} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + declare namespace ts { interface MapLike { [index: string]: T; @@ -1276,34 +419,15 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3, } - const enum RelationComparisonResult { - Succeeded = 1, - Failed = 2, - FailedAndReported = 3, - } interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; - modifierFlagsCache?: ModifierFlags; - transformFlags?: TransformFlags; decorators?: NodeArray; modifiers?: ModifiersArray; - id?: number; parent?: Node; - original?: Node; - startsOnNewLine?: boolean; - jsDoc?: JSDoc[]; - jsDocCache?: (JSDoc | JSDocTag)[]; - symbol?: Symbol; - locals?: SymbolTable; - nextContainer?: Node; - localSymbol?: Symbol; - flowNode?: FlowNode; - emitNode?: EmitNode; } interface NodeArray extends Array, TextRange { hasTrailingComma?: boolean; - transformFlags?: TransformFlags; } interface Token extends Node { kind: TKind; @@ -1319,27 +443,15 @@ declare namespace ts { type ReadonlyToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; - const enum GeneratedIdentifierKind { - None = 0, - Auto = 1, - Loop = 2, - Unique = 3, - Node = 4, - } interface Identifier extends PrimaryExpression { kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; - autoGenerateKind?: GeneratedIdentifierKind; - autoGenerateId?: number; isInJSDocNamespace?: boolean; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface GeneratedIdentifier extends Identifier { - autoGenerateKind: GeneratedIdentifierKind.Auto | GeneratedIdentifierKind.Loop | GeneratedIdentifierKind.Unique | GeneratedIdentifierKind.Node; - } interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; @@ -1587,7 +699,6 @@ declare namespace ts { } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; - textSourceNode?: Identifier | StringLiteral | NumericLiteral; } interface Expression extends Node { _expressionBrand: any; @@ -1596,10 +707,6 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { - kind: SyntaxKind.PartiallyEmittedExpression; - expression: Expression; - } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -1729,7 +836,6 @@ declare namespace ts { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; - isOctalLiteral?: boolean; } interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; @@ -1771,7 +877,6 @@ declare namespace ts { interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; - multiLine?: boolean; } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; @@ -1782,7 +887,6 @@ declare namespace ts { } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; - multiLine?: boolean; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; @@ -1897,15 +1001,6 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { - kind: SyntaxKind.NotEmittedStatement; - } - interface EndOfDeclarationMarker extends Statement { - kind: SyntaxKind.EndOfDeclarationMarker; - } - interface MergeDeclarationMarker extends Statement { - kind: SyntaxKind.MergeDeclarationMarker; - } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1920,7 +1015,6 @@ declare namespace ts { interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; - multiLine?: boolean; } interface VariableStatement extends Statement { kind: SyntaxKind.VariableStatement; @@ -1930,9 +1024,6 @@ declare namespace ts { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface PrologueDirective extends ExpressionStatement { - expression: StringLiteral; - } interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; @@ -2354,27 +1445,8 @@ declare namespace ts { typeReferenceDirectives: FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; - renamedDependencies?: Map; hasNoDefaultLib: boolean; languageVersion: ScriptTarget; - scriptKind: ScriptKind; - externalModuleIndicator: Node; - commonJsModuleIndicator: Node; - identifiers: Map; - nodeCount: number; - identifierCount: number; - symbolCount: number; - parseDiagnostics: Diagnostic[]; - additionalSyntacticDiagnostics?: Diagnostic[]; - bindDiagnostics: Diagnostic[]; - lineMap: number[]; - classifiableNames?: Map; - resolvedModules: Map; - resolvedTypeReferenceDirectiveNames: Map; - imports: LiteralExpression[]; - moduleAugmentations: LiteralExpression[]; - patternAmbientModules?: PatternAmbientModule[]; - ambientModuleNames: string[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -2407,18 +1479,6 @@ declare namespace ts { getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getTypeChecker(): TypeChecker; - getCommonSourceDirectory(): string; - getDiagnosticsProducingTypeChecker(): TypeChecker; - dropDiagnosticsProducingTypeChecker(): void; - getClassifiableNames(): Map; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; - getFileProcessingDiagnostics(): DiagnosticCollection; - getResolvedTypeReferenceDirectives(): Map; - isSourceFileFromExternalLibrary(file: SourceFile): boolean; - structureIsReused?: boolean; } interface SourceMapSpan { emittedLine: number; @@ -2449,13 +1509,6 @@ declare namespace ts { emitSkipped: boolean; diagnostics: Diagnostic[]; emittedFiles: string[]; - sourceMaps: SourceMapData[]; - } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - getResolvedTypeReferenceDirectives(): Map; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; @@ -2500,14 +1553,6 @@ declare namespace ts { getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol; - getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -2558,15 +1603,6 @@ declare namespace ts { WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } - const enum SymbolAccessibility { - Accessible = 0, - NotAccessible = 1, - CannotBeNamed = 2, - } - const enum SyntheticSymbolKind { - UnionOrIntersection = 0, - Spread = 1, - } const enum TypePredicateKind { This = 0, Identifier = 1, @@ -2584,61 +1620,6 @@ declare namespace ts { parameterIndex: number; } type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; - interface SymbolVisibilityResult { - accessibility: SymbolAccessibility; - aliasesToMakeVisible?: AnyImportSyntax[]; - errorSymbolName?: string; - errorNode?: Node; - } - interface SymbolAccessibilityResult extends SymbolVisibilityResult { - errorModuleName?: string; - } - enum TypeReferenceSerializationKind { - Unknown = 0, - TypeWithConstructSignatureAndValue = 1, - VoidNullableOrNeverType = 2, - NumberLikeType = 3, - StringLikeType = 4, - BooleanType = 5, - ArrayLikeType = 6, - ESSymbolType = 7, - Promise = 8, - TypeWithCallSignature = 9, - ObjectType = 10, - } - interface EmitResolver { - hasGlobalName(name: string): boolean; - getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration; - getReferencedImportDeclaration(node: Identifier): Declaration; - getReferencedDeclarationWithCollidingName(node: Identifier): Declaration; - isDeclarationWithCollidingName(node: Declaration): boolean; - isValueAliasDeclaration(node: Node): boolean; - isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; - isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; - getNodeCheckFlags(node: Node): NodeCheckFlags; - isDeclarationVisible(node: Declaration): boolean; - collectLinkedAliases(node: Identifier): Node[]; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; - writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; - isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - getReferencedValueDeclaration(reference: Identifier): Declaration; - getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind; - isOptionalParameter(node: ParameterDeclaration): boolean; - moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; - isArgumentsLocalBinding(node: Identifier): boolean; - getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; - getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; - getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; - isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; - writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter): void; - getJsxFactoryEntity(): EntityName; - } const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2705,7 +1686,6 @@ declare namespace ts { PropertyOrAccessor = 98308, Export = 7340032, ClassMember = 106500, - Classifiable = 788448, } interface Symbol { flags: SymbolFlags; @@ -2715,87 +1695,8 @@ declare namespace ts { members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; - isReadonly?: boolean; - id?: number; - mergeId?: number; - parent?: Symbol; - exportSymbol?: Symbol; - constEnumOnlyModule?: boolean; - isReferenced?: boolean; - isReplaceableByMethod?: boolean; - isAssigned?: boolean; - } - interface SymbolLinks { - target?: Symbol; - type?: Type; - declaredType?: Type; - typeParameters?: TypeParameter[]; - inferredClassType?: Type; - instantiations?: Map; - mapper?: TypeMapper; - referenced?: boolean; - containingType?: UnionOrIntersectionType; - leftSpread?: Symbol; - rightSpread?: Symbol; - hasNonUniformType?: boolean; - isPartial?: boolean; - isDiscriminantProperty?: boolean; - resolvedExports?: SymbolTable; - exportsChecked?: boolean; - isDeclarationWithCollidingName?: boolean; - bindingElement?: BindingElement; - exportsSomeValue?: boolean; - } - interface TransientSymbol extends Symbol, SymbolLinks { } type SymbolTable = Map; - interface Pattern { - prefix: string; - suffix: string; - } - interface PatternAmbientModule { - pattern: Pattern; - symbol: Symbol; - } - const enum NodeCheckFlags { - TypeChecked = 1, - LexicalThis = 2, - CaptureThis = 4, - CaptureNewTarget = 8, - SuperInstance = 256, - SuperStatic = 512, - ContextChecked = 1024, - AsyncMethodWithSuper = 2048, - AsyncMethodWithSuperBinding = 4096, - CaptureArguments = 8192, - EnumValuesComputed = 16384, - LexicalModuleMergesWithClass = 32768, - LoopWithCapturedBlockScopedBinding = 65536, - CapturedBlockScopedBinding = 131072, - BlockScopedBindingInLoop = 262144, - ClassWithBodyScopedClassBinding = 524288, - BodyScopedClassBinding = 1048576, - NeedsLoopOutParameter = 2097152, - AssignmentsMarked = 4194304, - ClassWithConstructorReference = 8388608, - ConstructorReferenceInClass = 16777216, - } - interface NodeLinks { - flags?: NodeCheckFlags; - resolvedType?: Type; - resolvedSignature?: Signature; - resolvedSymbol?: Symbol; - resolvedIndexInfo?: IndexInfo; - maybeTypePredicate?: boolean; - enumMemberValue?: number; - isVisible?: boolean; - hasReportedStatementInAmbientContext?: boolean; - jsxFlags?: JsxFlags; - resolvedJsxType?: Type; - hasSuperCall?: boolean; - superCall?: ExpressionStatement; - switchTypes?: Type[]; - } const enum TypeFlags { Any = 1, String = 2, @@ -2817,17 +1718,9 @@ declare namespace ts { Intersection = 131072, Index = 262144, IndexedAccess = 524288, - FreshLiteral = 1048576, - ContainsWideningType = 2097152, - ContainsObjectLiteral = 4194304, - ContainsAnyFunctionType = 8388608, - Nullable = 6144, Literal = 480, StringOrNumberLiteral = 96, - DefinitelyFalsy = 7392, PossiblyFalsy = 7406, - Intrinsic = 16015, - Primitive = 8190, StringLike = 262178, NumberLike = 340, BooleanLike = 136, @@ -2838,21 +1731,15 @@ declare namespace ts { TypeVariable = 540672, Narrowable = 1033215, NotUnionOrUnit = 33281, - RequiresWidening = 6291456, - PropagatingFlags = 14680064, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; - id: number; symbol?: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface IntrinsicType extends Type { - intrinsicName: string; - } interface LiteralType extends Type { text: string; freshType?: LiteralType; @@ -2885,8 +1772,6 @@ declare namespace ts { outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; thisType: TypeParameter; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -2900,59 +1785,23 @@ declare namespace ts { typeArguments: Type[]; } interface GenericType extends InterfaceType, TypeReference { - instantiations: Map; } interface UnionOrIntersectionType extends Type { types: Type[]; - resolvedProperties: SymbolTable; - resolvedIndexType: IndexType; - couldContainTypeVariables: boolean; } interface UnionType extends UnionOrIntersectionType { } interface IntersectionType extends UnionOrIntersectionType { } type StructuredType = ObjectType | UnionType | IntersectionType; - interface AnonymousType extends ObjectType { - target?: AnonymousType; - mapper?: TypeMapper; - } - interface MappedType extends ObjectType { - declaration: MappedTypeNode; - typeParameter?: TypeParameter; - constraintType?: Type; - templateType?: Type; - modifiersType?: Type; - mapper?: TypeMapper; - } interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface ResolvedType extends ObjectType, UnionOrIntersectionType { - members: SymbolTable; - properties: Symbol[]; - callSignatures: Signature[]; - constructSignatures: Signature[]; - stringIndexInfo?: IndexInfo; - numberIndexInfo?: IndexInfo; - } - interface FreshObjectLiteralType extends ResolvedType { - regularType: ResolvedType; - } - interface IterableOrIteratorType extends ObjectType, UnionType { - iterableElementType?: Type; - iteratorElementType?: Type; - } interface TypeVariable extends Type { - resolvedApparentType: Type; - resolvedIndexType: IndexType; } interface TypeParameter extends TypeVariable { constraint: Type; - target?: TypeParameter; - mapper?: TypeMapper; - isThisType?: boolean; } interface IndexedAccessType extends TypeVariable { objectType: Type; @@ -2970,18 +1819,6 @@ declare namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; - thisParameter?: Symbol; - resolvedReturnType: Type; - minArgumentCount: number; - hasRestParameter: boolean; - hasLiteralTypes: boolean; - target?: Signature; - mapper?: TypeMapper; - unionSignatures?: Signature[]; - erasedSignatureCache?: Signature; - isolatedSignatureType?: ObjectType; - typePredicate?: TypePredicate; - instantiations?: Map; } const enum IndexKind { String = 0, @@ -2992,33 +1829,6 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface TypeMapper { - (t: TypeParameter): Type; - mappedTypes?: Type[]; - instantiations?: Type[]; - context?: InferenceContext; - } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - topLevel: boolean; - isFixed: boolean; - } - interface InferenceContext { - signature: Signature; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - mapper?: TypeMapper; - failedTypeParameterIndex?: number; - } - const enum SpecialPropertyAssignmentKind { - None = 0, - ExportsProperty = 1, - ModuleExports = 2, - PrototypeProperty = 3, - ThisProperty = 4, - } interface FileExtensionInfo { extension: string; scriptKind: ScriptKind; @@ -3056,33 +1866,25 @@ declare namespace ts { type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; interface CompilerOptions { allowJs?: boolean; - allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; charset?: string; - configFilePath?: string; declaration?: boolean; declarationDir?: string; - diagnostics?: boolean; - extendedDiagnostics?: boolean; disableSizeLimit?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; - help?: boolean; importHelpers?: boolean; - init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; jsx?: JsxEmit; lib?: string[]; - listEmittedFiles?: boolean; - listFiles?: boolean; locale?: string; mapRoot?: string; maxNodeModuleJsDepth?: number; @@ -3090,7 +1892,6 @@ declare namespace ts { moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; - noEmitForJsFiles?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; @@ -3109,7 +1910,6 @@ declare namespace ts { paths?: MapLike; preserveConstEnums?: boolean; project?: string; - pretty?: DiagnosticStyle; reactNamespace?: string; jsxFactory?: string; removeComments?: boolean; @@ -3120,16 +1920,12 @@ declare namespace ts { sourceMap?: boolean; sourceRoot?: string; strictNullChecks?: boolean; - stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; - suppressOutputPathCheck?: boolean; target?: ScriptTarget; traceResolution?: boolean; types?: string[]; typeRoots?: string[]; - version?: boolean; - watch?: boolean; [option: string]: CompilerOptionsValue | undefined; } interface TypeAcquisition { @@ -3189,10 +1985,6 @@ declare namespace ts { Standard = 0, JSX = 1, } - const enum DiagnosticStyle { - Simple = 0, - Pretty = 1, - } interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3210,156 +2002,6 @@ declare namespace ts { fileNames: string[]; wildcardDirectories: MapLike; } - interface CommandLineOptionBase { - name: string; - type: "string" | "number" | "boolean" | "object" | "list" | Map; - isFilePath?: boolean; - shortName?: string; - description?: DiagnosticMessage; - paramType?: DiagnosticMessage; - experimental?: boolean; - isTSConfigOnly?: boolean; - } - interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase { - type: "string" | "number" | "boolean"; - } - interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: Map; - } - interface TsConfigOnlyOption extends CommandLineOptionBase { - type: "object"; - } - interface CommandLineOptionOfListType extends CommandLineOptionBase { - type: "list"; - element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType; - } - type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption | CommandLineOptionOfListType; - const enum CharacterCodes { - nullCharacter = 0, - maxAsciiCharacter = 127, - lineFeed = 10, - carriageReturn = 13, - lineSeparator = 8232, - paragraphSeparator = 8233, - nextLine = 133, - space = 32, - nonBreakingSpace = 160, - enQuad = 8192, - emQuad = 8193, - enSpace = 8194, - emSpace = 8195, - threePerEmSpace = 8196, - fourPerEmSpace = 8197, - sixPerEmSpace = 8198, - figureSpace = 8199, - punctuationSpace = 8200, - thinSpace = 8201, - hairSpace = 8202, - zeroWidthSpace = 8203, - narrowNoBreakSpace = 8239, - ideographicSpace = 12288, - mathematicalSpace = 8287, - ogham = 5760, - _ = 95, - $ = 36, - _0 = 48, - _1 = 49, - _2 = 50, - _3 = 51, - _4 = 52, - _5 = 53, - _6 = 54, - _7 = 55, - _8 = 56, - _9 = 57, - a = 97, - b = 98, - c = 99, - d = 100, - e = 101, - f = 102, - g = 103, - h = 104, - i = 105, - j = 106, - k = 107, - l = 108, - m = 109, - n = 110, - o = 111, - p = 112, - q = 113, - r = 114, - s = 115, - t = 116, - u = 117, - v = 118, - w = 119, - x = 120, - y = 121, - z = 122, - A = 65, - B = 66, - C = 67, - D = 68, - E = 69, - F = 70, - G = 71, - H = 72, - I = 73, - J = 74, - K = 75, - L = 76, - M = 77, - N = 78, - O = 79, - P = 80, - Q = 81, - R = 82, - S = 83, - T = 84, - U = 85, - V = 86, - W = 87, - X = 88, - Y = 89, - Z = 90, - ampersand = 38, - asterisk = 42, - at = 64, - backslash = 92, - backtick = 96, - bar = 124, - caret = 94, - closeBrace = 125, - closeBracket = 93, - closeParen = 41, - colon = 58, - comma = 44, - dot = 46, - doubleQuote = 34, - equals = 61, - exclamation = 33, - greaterThan = 62, - hash = 35, - lessThan = 60, - minus = 45, - openBrace = 123, - openBracket = 91, - openParen = 40, - percent = 37, - plus = 43, - question = 63, - semicolon = 59, - singleQuote = 39, - slash = 47, - tilde = 126, - backspace = 8, - formFeed = 12, - byteOrderMark = 65279, - tab = 9, - verticalTab = 11, - } interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string; @@ -3386,7 +2028,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -3412,157 +2053,6 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } - const enum TransformFlags { - None = 0, - TypeScript = 1, - ContainsTypeScript = 2, - ContainsJsx = 4, - ContainsESNext = 8, - ContainsES2017 = 16, - ContainsES2016 = 32, - ES2015 = 64, - ContainsES2015 = 128, - Generator = 256, - ContainsGenerator = 512, - DestructuringAssignment = 1024, - ContainsDestructuringAssignment = 2048, - ContainsDecorators = 4096, - ContainsPropertyInitializer = 8192, - ContainsLexicalThis = 16384, - ContainsCapturedLexicalThis = 32768, - ContainsLexicalThisInComputedPropertyName = 65536, - ContainsDefaultValueAssignments = 131072, - ContainsParameterPropertyAssignments = 262144, - ContainsSpread = 524288, - ContainsObjectSpread = 1048576, - ContainsRest = 524288, - ContainsObjectRest = 1048576, - ContainsComputedPropertyName = 2097152, - ContainsBlockScopedBinding = 4194304, - ContainsBindingPattern = 8388608, - ContainsYield = 16777216, - ContainsHoistedDeclarationOrCompletion = 33554432, - HasComputedFlags = 536870912, - AssertTypeScript = 3, - AssertJsx = 4, - AssertESNext = 8, - AssertES2017 = 16, - AssertES2016 = 32, - AssertES2015 = 192, - AssertGenerator = 768, - AssertDestructuringAssignment = 3072, - NodeExcludes = 536872257, - ArrowFunctionExcludes = 601249089, - FunctionExcludes = 601281857, - ConstructorExcludes = 601015617, - MethodOrAccessorExcludes = 601015617, - ClassExcludes = 539358529, - ModuleExcludes = 574674241, - TypeExcludes = -3, - ObjectLiteralExcludes = 540087617, - ArrayLiteralOrCallOrNewExcludes = 537396545, - VariableDeclarationListExcludes = 546309441, - ParameterExcludes = 536872257, - CatchClauseExcludes = 537920833, - BindingPatternExcludes = 537396545, - TypeScriptClassSyntaxMask = 274432, - ES2015FunctionSyntaxMask = 163840, - } - interface EmitNode { - annotatedNodes?: Node[]; - flags?: EmitFlags; - commentRange?: TextRange; - sourceMapRange?: TextRange; - tokenSourceMapRanges?: Map; - constantValue?: number; - externalHelpersModuleName?: Identifier; - helpers?: EmitHelper[]; - } - const enum EmitFlags { - SingleLine = 1, - AdviseOnEmitNode = 2, - NoSubstitution = 4, - CapturesThis = 8, - NoLeadingSourceMap = 16, - NoTrailingSourceMap = 32, - NoSourceMap = 48, - NoNestedSourceMaps = 64, - NoTokenLeadingSourceMaps = 128, - NoTokenTrailingSourceMaps = 256, - NoTokenSourceMaps = 384, - NoLeadingComments = 512, - NoTrailingComments = 1024, - NoComments = 1536, - NoNestedComments = 2048, - HelperName = 4096, - ExportName = 8192, - LocalName = 16384, - Indented = 32768, - NoIndentation = 65536, - AsyncFunctionBody = 131072, - ReuseTempVariableScope = 262144, - CustomPrologue = 524288, - NoHoisting = 1048576, - HasEndOfDeclarationMarker = 2097152, - } - interface EmitHelper { - readonly name: string; - readonly scoped: boolean; - readonly text: string; - readonly priority?: number; - } - const enum ExternalEmitHelpers { - Extends = 1, - Assign = 2, - Rest = 4, - Decorate = 8, - Metadata = 16, - Param = 32, - Awaiter = 64, - Generator = 128, - FirstEmitHelper = 1, - LastEmitHelper = 128, - } - const enum EmitContext { - SourceFile = 0, - Expression = 1, - IdentifierName = 2, - Unspecified = 3, - } - interface EmitHost extends ScriptReferenceHost { - getSourceFiles(): SourceFile[]; - isSourceFileFromExternalLibrary(file: SourceFile): boolean; - getCommonSourceDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - isEmitBlocked(emitFileName: string): boolean; - writeFile: WriteFileCallback; - } - interface TransformationContext { - getCompilerOptions(): CompilerOptions; - getEmitResolver(): EmitResolver; - getEmitHost(): EmitHost; - startLexicalEnvironment(): void; - suspendLexicalEnvironment(): void; - resumeLexicalEnvironment(): void; - endLexicalEnvironment(): Statement[]; - hoistFunctionDeclaration(node: FunctionDeclaration): void; - hoistVariableDeclaration(node: Identifier): void; - requestEmitHelper(helper: EmitHelper): void; - readEmitHelpers(): EmitHelper[] | undefined; - enableSubstitution(kind: SyntaxKind): void; - isSubstitutionEnabled(node: Node): boolean; - onSubstituteNode?: (emitContext: EmitContext, node: Node) => Node; - enableEmitNotification(kind: SyntaxKind): void; - isEmitNotificationEnabled(node: Node): boolean; - onEmitNode?: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; - } - interface TransformationResult { - transformed: SourceFile[]; - emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - } - type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile; interface TextSpan { start: number; length: number; @@ -3571,238 +2061,13 @@ declare namespace ts { span: TextSpan; newLength: number; } - interface DiagnosticCollection { - add(diagnostic: Diagnostic): void; - getGlobalDiagnostics(): Diagnostic[]; - getDiagnostics(fileName?: string): Diagnostic[]; - getModificationCount(): number; - reattachFileDiagnostics(newFile: SourceFile): void; - } interface SyntaxList extends Node { _children: Node[]; } } -declare namespace ts { - const timestamp: () => number; -} -declare namespace ts.performance { - function mark(markName: string): void; - function measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - function getCount(markName: string): number; - function getDuration(measureName: string): number; - function forEachMeasure(cb: (measureName: string, duration: number) => void): void; - function enable(): void; - function disable(): void; -} declare namespace ts { const version = "2.2.0"; } -declare namespace ts { - const enum Ternary { - False = 0, - Maybe = 1, - True = -1, - } - const collator: { - compare(a: string, b: string): number; - }; - function createMap(template?: MapLike): Map; - function createFileMap(keyMapper?: (key: string) => string): FileMap; - function toPath(fileName: string, basePath: string, getCanonicalFileName: (path: string) => string): Path; - const enum Comparison { - LessThan = -1, - EqualTo = 0, - GreaterThan = 1, - } - function forEach(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined; - function zipWith(arrayA: T[], arrayB: U[], callback: (a: T, b: U, index: number) => void): void; - function every(array: T[], callback: (element: T, index: number) => boolean): boolean; - function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined; - function findMap(array: T[], callback: (element: T, index: number) => U | undefined): U; - function contains(array: T[], value: T): boolean; - function indexOf(array: T[], value: T): number; - function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number; - function countWhere(array: T[], predicate: (x: T, i: number) => boolean): number; - function filter(array: T[], f: (x: T) => x is U): U[]; - function filter(array: T[], f: (x: T) => boolean): T[]; - function removeWhere(array: T[], f: (x: T) => boolean): boolean; - function filterMutate(array: T[], f: (x: T) => boolean): void; - function map(array: T[], f: (x: T, i: number) => U): U[]; - function sameMap(array: T[], f: (x: T, i: number) => T): T[]; - function flatten(array: (T | T[])[]): T[]; - function flatMap(array: T[], mapfn: (x: T, i: number) => U | U[]): U[]; - function span(array: T[], f: (x: T, i: number) => boolean): [T[], T[]]; - function spanMap(array: T[], keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[]; - function mapObject(object: MapLike, f: (key: string, x: T) => [string, U]): MapLike; - function some(array: T[], predicate?: (value: T) => boolean): boolean; - function concatenate(array1: T[], array2: T[]): T[]; - function deduplicate(array: T[], areEqual?: (a: T, b: T) => boolean): T[]; - function arrayIsEqualTo(array1: ReadonlyArray, array2: ReadonlyArray, equaler?: (a: T, b: T) => boolean): boolean; - function changesAffectModuleResolution(oldOptions: CompilerOptions, newOptions: CompilerOptions): boolean; - function compact(array: T[]): T[]; - function relativeComplement(arrayA: T[] | undefined, arrayB: T[] | undefined, comparer?: (x: T, y: T) => Comparison, offsetA?: number, offsetB?: number): T[] | undefined; - function sum(array: any[], prop: string): number; - function append(to: T[] | undefined, value: T | undefined): T[] | undefined; - function addRange(to: T[] | undefined, from: T[] | undefined): T[] | undefined; - function stableSort(array: T[], comparer?: (x: T, y: T) => Comparison): T[]; - function rangeEquals(array1: T[], array2: T[], pos: number, end: number): boolean; - function firstOrUndefined(array: T[]): T; - function lastOrUndefined(array: T[]): T; - function singleOrUndefined(array: T[]): T; - function singleOrMany(array: T[]): T | T[]; - function replaceElement(array: T[], index: number, value: T): T[]; - function binarySearch(array: T[], value: T, comparer?: (v1: T, v2: T) => number, offset?: number): number; - function reduceLeft(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceLeft(array: T[], f: (memo: T, value: T, i: number) => T): T; - function reduceRight(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceRight(array: T[], f: (memo: T, value: T, i: number) => T): T; - function hasProperty(map: MapLike, key: string): boolean; - function getProperty(map: MapLike, key: string): T | undefined; - function getOwnKeys(map: MapLike): string[]; - function forEachProperty(map: Map, callback: (value: T, key: string) => U): U; - function someProperties(map: Map, predicate?: (value: T, key: string) => boolean): boolean; - function copyProperties(source: Map, target: MapLike): void; - function appendProperty(map: Map, key: string | number, value: T): Map; - function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; - function assign, T2>(t: T1, arg1: T2): T1 & T2; - function assign>(t: T1, ...args: any[]): any; - function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U; - function equalOwnProperties(left: MapLike, right: MapLike, equalityComparer?: (left: T, right: T) => boolean): boolean; - function arrayToMap(array: T[], makeKey: (value: T) => string): Map; - function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue: (value: T) => U): Map; - function isEmpty(map: Map): boolean; - function cloneMap(map: Map): Map; - function clone(object: T): T; - function extend(first: T1, second: T2): T1 & T2; - function multiMapAdd(map: Map, key: string | number, value: V): V[]; - function multiMapRemove(map: Map, key: string, value: V): void; - function isArray(value: any): value is any[]; - function noop(): void; - function notImplemented(): never; - function memoize(callback: () => T): () => T; - function chain(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U; - function compose(...args: ((t: T) => T)[]): (t: T) => T; - function formatStringFromArgs(text: string, args: { - [index: number]: string; - }, baseIndex?: number): string; - let localizedDiagnosticMessages: Map; - function getLocaleSpecificMessage(message: DiagnosticMessage): string; - function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; - function formatMessage(_dummy: any, message: DiagnosticMessage): string; - function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; - function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic; - function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain; - function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; - function compareValues(a: T, b: T): Comparison; - function compareStrings(a: string, b: string, ignoreCase?: boolean): Comparison; - function compareStringsCaseInsensitive(a: string, b: string): Comparison; - function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison; - function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; - function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; - function normalizeSlashes(path: string): string; - function getRootLength(path: string): number; - const directorySeparator = "/"; - function normalizePath(path: string): string; - function pathEndsWithDirectorySeparator(path: string): boolean; - function getDirectoryPath(path: Path): Path; - function getDirectoryPath(path: string): string; - function isUrl(path: string): boolean; - function isExternalModuleNameRelative(moduleName: string): boolean; - function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; - function getEmitModuleKind(compilerOptions: CompilerOptions): ModuleKind; - function getEmitModuleResolutionKind(compilerOptions: CompilerOptions): ModuleResolutionKind; - function hasZeroOrOneAsteriskCharacter(str: string): boolean; - function isRootedDiskPath(path: string): boolean; - function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string; - function getNormalizedPathComponents(path: string, currentDirectory: string): string[]; - function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string; - function getNormalizedPathFromPathComponents(pathComponents: string[]): string; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string; - function getBaseFileName(path: string): string; - function combinePaths(path1: string, path2: string): string; - function removeTrailingDirectorySeparator(path: string): string; - function ensureTrailingDirectorySeparator(path: string): string; - function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; - function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; - function startsWith(str: string, prefix: string): boolean; - function endsWith(str: string, suffix: string): boolean; - function hasExtension(fileName: string): boolean; - function fileExtensionIs(path: string, extension: string): boolean; - function fileExtensionIsAny(path: string, extensions: string[]): boolean; - function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string; - function isImplicitGlob(lastPathComponent: string): boolean; - interface FileSystemEntries { - files: string[]; - directories: string[]; - } - interface FileMatcherPatterns { - includeFilePattern: string; - includeDirectoryPattern: string; - excludePattern: string; - basePaths: string[]; - } - function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns; - function matchFiles(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string, getFileSystemEntries: (path: string) => FileSystemEntries): string[]; - function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind; - function getScriptKindFromFileName(fileName: string): ScriptKind; - const supportedTypeScriptExtensions: string[]; - const supportedTypescriptExtensionsForExtractExtension: string[]; - const supportedJavascriptExtensions: string[]; - function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[]; - function hasJavaScriptFileExtension(fileName: string): boolean; - function hasTypeScriptFileExtension(fileName: string): boolean; - function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): boolean; - const enum ExtensionPriority { - TypeScriptFiles = 0, - DeclarationAndJavaScriptFiles = 2, - Limit = 5, - Highest = 0, - Lowest = 2, - } - function getExtensionPriority(path: string, supportedExtensions: string[]): ExtensionPriority; - function adjustExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; - function removeFileExtension(path: string): string; - function tryRemoveExtension(path: string, extension: string): string | undefined; - function removeExtension(path: string, extension: string): string; - function changeExtension(path: T, newExtension: string): T; - interface ObjectAllocator { - getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; - getTokenConstructor(): new (kind: TKind, pos?: number, end?: number) => Token; - getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier; - getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile; - getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; - getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; - getSignatureConstructor(): new (checker: TypeChecker) => Signature; - } - let objectAllocator: ObjectAllocator; - const enum AssertionLevel { - None = 0, - Normal = 1, - Aggressive = 2, - VeryAggressive = 3, - } - namespace Debug { - let currentAssertionLevel: AssertionLevel; - function shouldAssert(level: AssertionLevel): boolean; - function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void; - function fail(message?: string): void; - } - function orderedRemoveItem(array: T[], item: T): boolean; - function orderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItem(array: T[], item: T): void; - function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string; - function matchPatternOrExact(patternStrings: string[], candidate: string): string | Pattern | undefined; - function patternText({prefix, suffix}: Pattern): string; - function matchedText(pattern: Pattern, candidate: string): string; - function findBestPatternMatch(values: T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined; - function tryParsePattern(pattern: string): Pattern | undefined; - function positionIsSynthesized(pos: number): boolean; - function extensionIsTypeScript(ext: Extension): boolean; - function extensionFromPath(path: string): Extension; - function tryGetExtensionFromPath(path: string): Extension | undefined; -} declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -3834,8 +2099,6 @@ declare namespace ts { getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; - getEnvironmentVariable(name: string): string; - tryEnableSourceMapsForHost?(): void; setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; clearTimeout?(timeoutId: any): void; } @@ -3848,4935 +2111,10 @@ declare namespace ts { } let sys: System; } -declare namespace ts { - const Diagnostics: { - Unterminated_string_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_file_cannot_have_a_reference_to_itself: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trailing_comma_not_allowed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Asterisk_Slash_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_must_be_last_in_a_parameter_list: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_cannot_have_question_mark_and_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_required_parameter_cannot_follow_an_optional_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_cannot_have_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_a_question_mark: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_must_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_must_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_type_must_be_string_or_number: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessibility_modifier_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_must_precede_1_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_class_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_followed_by_an_argument_list_or_member_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_ambient_modules_can_use_quoted_names: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Statements_are_not_allowed_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializers_are_not_allowed_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_with_a_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_data_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_module_or_namespace_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_0_modifier_cannot_be_used_with_an_interface_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_cannot_be_optional: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_must_have_exactly_one_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_an_optional_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_get_accessor_cannot_have_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Operand_for_await_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_member_must_have_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_be_used_in_a_namespace: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_type_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_an_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_0_modifier_cannot_be_used_with_an_import_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_reference_directive_syntax: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_accessor_cannot_be_declared_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameters_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_annotation_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_accessor_cannot_have_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_a_return_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_must_have_exactly_one_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - with_statements_are_not_allowed_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - delete_cannot_be_called_on_an_identifier_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Jump_target_cannot_cross_function_boundary: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_return_statement_can_only_be_used_within_a_function_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_label_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_allowed_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_tuple_type_element_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_declaration_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Hexadecimal_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_end_of_text: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_or_statement_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Statement_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - case_or_default_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_or_signature_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_member_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_expression_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_assignment_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_or_comma_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - String_literal_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Line_break_not_permitted_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - or_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declarations_in_a_namespace_cannot_reference_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_declarations_must_be_initialized: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_declarations_can_only_be_declared_inside_a_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - let_declarations_can_only_be_declared_inside_a_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_template_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_regular_expression_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_member_cannot_be_declared_optional: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_yield_expression_is_only_allowed_in_a_generator_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Computed_property_names_are_not_allowed_in_enums: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_comma_expression_is_not_allowed_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - extends_clause_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - extends_clause_must_precede_implements_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Classes_can_only_extend_a_single_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - implements_clause_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_declaration_cannot_have_implements_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Binary_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_destructuring_pattern_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Array_element_destructuring_pattern_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_destructuring_declaration_must_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_implementation_cannot_be_declared_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Modifiers_cannot_appear_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Merge_conflict_marker_encountered: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_may_not_be_declared_using_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_declaration_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_no_default_export: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_declaration_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_declarations_are_not_permitted_in_a_namespace: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_cannot_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_Unicode_escape_sequence: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Line_terminator_not_permitted_before_arrow: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Decorators_are_not_valid_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_declaration_without_the_default_modifier_must_have_a_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_assignment_is_not_supported_when_module_flag_is_system: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generators_are_not_allowed_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_overload_signature_cannot_be_declared_as_a_generator: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_tag_already_specified: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Signature_0_must_have_a_type_predicate: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_parameter_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_predicate_0_is_not_assignable_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_is_not_in_the_same_position_as_parameter_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_cannot_reference_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_can_only_be_used_in_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_declaration_can_only_be_used_in_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_with_1_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Abstract_methods_can_only_appear_within_an_abstract_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_property_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_literal_property_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_member_cannot_have_the_0_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - with_statements_are_not_allowed_in_an_async_function_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - await_expression_is_only_allowed_within_an_async_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_body_of_an_if_statement_cannot_be_the_empty_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_in_module_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_in_declaration_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_at_top_level: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_cannot_be_declared_using_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_abstract_accessor_cannot_have_an_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Static_members_cannot_reference_class_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circular_definition_of_import_alias_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_is_not_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_module_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_recursively_references_itself_as_a_base_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_may_only_extend_another_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_may_only_extend_a_class_or_another_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_has_a_circular_constraint: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generic_type_0_requires_1_type_argument_s: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_generic: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_type_0_must_be_a_class_or_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_type_0_must_have_1_type_parameter_s: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_global_type_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Named_property_0_of_types_1_and_2_are_not_identical: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_0_cannot_simultaneously_extend_types_1_and_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Excessive_stack_depth_comparing_types_0_and_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_assignable_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_exported_variable_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_missing_in_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_private_in_type_1_but_not_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_of_property_0_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_optional_in_type_1_but_required_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_of_parameters_0_and_1_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signature_is_missing_in_type_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signatures_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_module_or_namespace_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_current_location: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_constructor_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_static_property_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_can_only_be_referenced_in_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_cannot_be_referenced_in_constructor_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_does_not_exist_on_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_private_and_only_accessible_within_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_does_not_satisfy_the_constraint_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Supplied_parameters_do_not_match_any_signature_of_call_target: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Untyped_function_calls_may_not_accept_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_void_function_can_be_called_with_the_new_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_converted_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Operator_0_cannot_be_applied_to_types_1_and_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_must_be_of_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_cannot_be_referenced_in_its_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_string_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_number_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructors_for_derived_classes_must_contain_a_super_call: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_get_accessor_must_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Getter_and_setter_accessors_do_not_agree_in_visibility: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - get_and_set_accessor_must_have_the_same_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_exported_or_non_exported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_ambient_or_non_ambient: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_public_private_or_protected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_optional_or_required: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_overload_must_be_static: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_overload_must_not_be_static: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implementation_name_must_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_implementation_is_missing: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Multiple_constructor_implementations_are_not_allowed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_function_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signature_is_not_compatible_with_function_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_name_conflicts_with_built_in_global_identifier_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Setters_cannot_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_incorrectly_extends_base_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_incorrectly_implements_interface_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_may_only_implement_another_class_or_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_0_must_have_identical_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_0_incorrectly_extends_interface_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_module_declaration_cannot_specify_relative_module_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declaration_conflicts_with_local_declaration_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_have_separate_declarations_of_a_private_property_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_in_type_1_but_public_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Block_scoped_variable_0_used_before_its_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_block_scoped_variable_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_enum_member_cannot_have_a_numeric_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_is_used_before_being_assigned: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_alias_0_circularly_references_itself: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_alias_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_AMD_module_cannot_have_multiple_name_assignments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_property_1_and_no_string_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_property_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_must_be_last_in_a_destructuring_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_cannot_be_referenced_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_global_value_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_0_operator_cannot_be_applied_to_type_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_declarations_must_all_be_const_or_non_const: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_const_enum_declarations_member_initializer_must_be_constant_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_does_not_exist_on_const_enum_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_declaration_conflicts_with_exported_declaration_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_iterator_must_have_a_next_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_identifier_0_in_catch_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_an_array_type_or_a_string_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_cannot_contain_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_namespace_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_generator_cannot_have_a_void_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_a_constructor_function_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_base_constructor_has_the_specified_number_of_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_constructors_must_all_have_the_same_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_create_an_instance_of_the_abstract_class_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_abstract_or_non_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Classes_containing_abstract_methods_must_be_marked_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_an_abstract_method_must_be_consecutive: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - yield_expressions_cannot_be_used_in_a_parameter_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - await_expressions_cannot_be_used_in_a_parameter_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_module_cannot_have_multiple_default_exports: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_incompatible_with_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_null: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_null_or_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_returning_never_cannot_have_a_reachable_end_point: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_type_0_has_members_with_initializers_that_are_not_literals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_used_to_index_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_matching_index_signature_for_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_used_as_an_index_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_to_0_because_it_is_not_a_variable: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signature_in_type_0_only_permits_reading: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_attributes_type_0_may_not_be_a_union_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_in_type_1_is_not_assignable_to_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_global_type_JSX_0_may_not_have_more_than_one_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_spread_child_must_be_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_emit_namespaced_JSX_elements_in_React: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_expressions_must_have_one_parent_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_provides_no_match_for_the_signature_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_module_name_in_augmentation_module_0_cannot_be_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessors_must_both_be_abstract_or_non_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_comparable_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_parameter_must_be_the_first_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_constructor_cannot_have_a_this_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - get_and_set_accessor_must_have_the_same_this_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_this_types_of_each_signature_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_0_must_have_identical_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_type_definition_file_for_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_extend_an_interface_0_Did_you_mean_implements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_must_be_declared_after_its_base_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Namespace_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Spread_types_may_only_be_created_from_object_types: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Rest_types_may_only_be_created_from_object_types: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_operand_of_a_delete_operator_must_be_a_property_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declaration_0_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_type_alias_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Default_export_of_the_module_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_current_host_does_not_support_the_0_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_the_common_subdirectory_path_for_the_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_read_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unsupported_file_encoding: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Failed_to_parse_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_compiler_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compiler_option_0_requires_a_value_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Could_not_write_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_cannot_be_specified_without_specifying_option_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_cannot_be_specified_with_option_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_tsconfig_json_file_is_already_defined_at_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_write_file_0_because_it_would_overwrite_input_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_specified_path_does_not_exist_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_paths_cannot_be_used_without_specifying_baseUrl_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Pattern_0_can_have_at_most_one_Asterisk_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitutions_for_pattern_0_should_be_an_array: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Concatenate_and_emit_output_to_single_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generates_corresponding_d_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Watch_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Redirect_output_structure_to_the_directory: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_erase_const_enum_declarations_in_generated_code: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_outputs_if_any_errors_were_reported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_comments_to_output: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_outputs: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Skip_type_checking_of_declaration_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Print_this_message: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Print_the_compiler_s_version: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compile_the_project_in_the_given_directory: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Syntax_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - options: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Examples_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Options_Colon: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Version_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Insert_command_line_options_and_files_from_a_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_change_detected_Starting_incremental_compilation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - KIND: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - FILE: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - VERSION: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - LOCATION: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - DIRECTORY: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - STRATEGY: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compilation_complete_Watching_for_file_changes: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generates_corresponding_map_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compiler_option_0_expects_an_argument: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_quoted_string_in_response_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_for_0_option_must_be_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unsupported_locale_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_open_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Corrupted_locale_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_not_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - NEWLINE: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_can_only_be_specified_in_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_ES7_decorators: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_ES7_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Successfully_created_a_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Suppress_excess_property_checks_for_object_literals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Stylize_errors_and_messages_using_color_and_context_experimental: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_report_errors_on_unused_labels: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_error_when_not_all_code_paths_in_function_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_for_fallthrough_cases_in_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_report_errors_on_unreachable_code: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Disallow_inconsistently_cased_references_to_the_same_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_library_files_to_be_included_in_the_compilation_Colon: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_JSX_code_generation_Colon_preserve_or_react: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_has_an_unsupported_extension_so_skipping_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_amd_and_system_modules_are_supported_alongside_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_directory_to_resolve_non_absolute_module_names: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enable_tracing_of_the_name_resolution_process: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_module_0_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Explicitly_specified_module_resolution_kind_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_resolution_kind_is_not_specified_using_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_was_successfully_resolved_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_was_not_resolved: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_matched_pattern_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trying_substitution_0_candidate_module_location_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_module_name_0_relative_to_base_url_1_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_does_not_exist: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_exist_use_it_as_a_name_resolution_result: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_module_0_from_node_modules_folder_target_file_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Found_package_json_at_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - package_json_does_not_have_a_types_or_main_field: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - package_json_has_0_field_1_that_references_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Allow_javascript_files_to_be_compiled: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_should_have_array_of_strings_as_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Checking_if_0_is_the_longest_matching_prefix_for_1_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expected_type_of_0_field_in_package_json_to_be_string_got_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Longest_matching_prefix_for_0_is_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_0_from_the_root_dir_1_candidate_location_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trying_other_entries_in_rootDirs: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_resolution_using_rootDirs_has_failed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_use_strict_directives_in_module_output: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enable_strict_null_checks: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_option_excludes_Did_you_mean_exclude: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Raise_error_on_this_expressions_with_an_implied_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_1_root_directory_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_using_primary_search_paths: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_from_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_reference_directive_0_was_not_resolved: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_with_primary_search_path_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Root_directory_cannot_be_determined_skipping_primary_search_paths: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_declaration_files_to_be_included_in_compilation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Looking_up_in_node_modules_folder_initial_location_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_config_file_0_found_doesn_t_contain_any_source_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_real_path_for_0_result_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_name_0_has_a_1_extension_stripping_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_declared_but_never_used: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_on_unused_locals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_on_unused_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_types_specified_in_package_json_so_returning_main_value_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_declared_but_never_used: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_emit_helpers_from_tslib: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_to_1_but_jsx_is_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_to_1_but_allowJs_is_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolution_for_module_0_was_found_in_cache: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Directory_0_does_not_exist_skipping_all_lookups_in_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Member_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_literal_s_property_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Rest_parameter_0_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _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: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - 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: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unreachable_code_detected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unused_label: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Fallthrough_case_in_switch: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Not_all_code_paths_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Binding_element_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - You_cannot_rename_this_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - import_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - export_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_parameter_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - implements_clauses_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - interface_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - module_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_aliases_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - types_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_arguments_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - parameter_modifiers_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - enum_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_assertion_expressions_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - class_expressions_are_not_currently_supported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Language_service_is_disabled: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expected_corresponding_JSX_closing_tag_for_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_attribute_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_0_has_no_corresponding_closing_tag: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_type_acquisition_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circularity_detected_while_resolving_configuration_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_files_list_in_config_file_0_is_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Add_missing_super_call: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Make_super_call_the_first_statement_in_the_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Change_extends_to_implements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Remove_unused_identifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_inherited_abstract_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_0_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Change_0_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Add_0_to_existing_import_declaration_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - }; -} declare namespace ts { interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } - function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean; interface Scanner { getStartPos(): number; getToken(): SyntaxKind; @@ -8808,24 +2146,13 @@ declare namespace ts { scanRange(start: number, length: number, callback: () => T): T; tryScan(callback: () => T): T; } - function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget): boolean; function tokenToString(t: SyntaxKind): string; - function stringToToken(s: string): SyntaxKind; - function computeLineStarts(text: string): number[]; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; - function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number; - function getLineStarts(sourceFile: SourceFile): number[]; - function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): { - line: number; - character: number; - }; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isWhiteSpaceSingleLine(ch: number): boolean; function isLineBreak(ch: number): boolean; - function isOctalDigit(ch: number): boolean; function couldStartTrivia(text: string, pos: number): boolean; - function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean, stopAtComments?: boolean): number; function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; @@ -8835,23 +2162,9 @@ declare namespace ts { function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierText(name: string, languageVersion: ScriptTarget): boolean; function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { - const compileOnSaveCommandLineOption: CommandLineOption; - const optionDeclarations: CommandLineOption[]; - let typeAcquisitionDeclarations: CommandLineOption[]; - interface OptionNameMap { - optionNameMap: Map; - shortOptionNames: Map; - } - const defaultInitCompilerOptions: CompilerOptions; - function convertEnableAutoDiscoveryToEnable(typeAcquisition: TypeAcquisition): TypeAcquisition; - function getOptionNameMap(): OptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic; - function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]): string | number; - function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] | undefined; function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; @@ -8861,9 +2174,6 @@ declare namespace ts { config?: any; error?: Diagnostic; }; - function generateTSConfig(options: CompilerOptions, fileNames: string[]): { - compilerOptions: Map; - }; function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: FileExtensionInfo[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { @@ -8875,114 +2185,7 @@ declare namespace ts { errors: Diagnostic[]; }; } -declare namespace ts.JsTyping { - interface TypingResolutionHost { - directoryExists: (path: string) => boolean; - fileExists: (fileName: string) => boolean; - readFile: (path: string, encoding?: string) => string; - readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; - } - const nodeCoreModuleList: ReadonlyArray; - function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typeAcquisition: TypeAcquisition, unresolvedImports: ReadonlyArray): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; -} -declare namespace ts.server { - const ActionSet: ActionSet; - const ActionInvalidate: ActionInvalidate; - const EventBeginInstallTypes: EventBeginInstallTypes; - const EventEndInstallTypes: EventEndInstallTypes; - namespace Arguments { - const GlobalCacheLocation = "--globalTypingsCacheLocation"; - const LogFile = "--logFile"; - const EnableTelemetry = "--enableTelemetry"; - } - function hasArgument(argumentName: string): boolean; - function findArgument(argumentName: string): string; -} -declare namespace ts.server { - enum LogLevel { - terse = 0, - normal = 1, - requestTime = 2, - verbose = 3, - } - const emptyArray: ReadonlyArray; - interface Logger { - close(): void; - hasLevel(level: LogLevel): boolean; - loggingEnabled(): boolean; - perftrc(s: string): void; - info(s: string): void; - startGroup(): void; - endGroup(): void; - msg(s: string, type?: Msg.Types): void; - getLogFileName(): string; - } - namespace Msg { - type Err = "Err"; - const Err: Err; - type Info = "Info"; - const Info: Info; - type Perf = "Perf"; - const Perf: Perf; - type Types = Err | Info | Perf; - } - function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; - namespace Errors { - function ThrowNoProject(): never; - function ThrowProjectLanguageServiceDisabled(): never; - function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; - } - function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; - function mergeMaps(target: MapLike, source: MapLike): void; - function removeItemFromSet(items: T[], itemToRemove: T): void; - type NormalizedPath = string & { - __normalizedPathTag: any; - }; - function toNormalizedPath(fileName: string): NormalizedPath; - function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; - function asNormalizedPath(fileName: string): NormalizedPath; - interface NormalizedPathMap { - get(path: NormalizedPath): T; - set(path: NormalizedPath, value: T): void; - contains(path: NormalizedPath): boolean; - remove(path: NormalizedPath): void; - } - function createNormalizedPathMap(): NormalizedPathMap; - interface ProjectOptions { - configHasFilesProperty?: boolean; - files?: string[]; - wildcardDirectories?: Map; - compilerOptions?: CompilerOptions; - typeAcquisition?: TypeAcquisition; - compileOnSave?: boolean; - } - function isInferredProjectName(name: string): boolean; - function makeInferredProjectName(counter: number): string; - function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; - class ThrottledOperations { - private readonly host; - private pendingTimeouts; - constructor(host: ServerHost); - schedule(operationId: string, delay: number, cb: () => void): void; - private static run(self, operationId, cb); - } - class GcTimer { - private readonly host; - private readonly delay; - private readonly logger; - private timerId; - constructor(host: ServerHost, delay: number, logger: Logger); - scheduleCollect(): void; - private static run(self); - } -} declare namespace ts { - function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; - function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; function moduleHasNonRelativeName(moduleName: string): boolean; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; @@ -9003,396 +2206,7 @@ declare namespace ts { function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; - function directoryProbablyExists(directoryName: string, host: { - directoryExists?: (directoryName: string) => boolean; - }): boolean; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; - function loadModuleFromGlobalCache(moduleName: string, projectName: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string): ResolvedModuleWithFailedLookupLocations; -} -declare namespace ts { - const externalHelpersModuleNameText = "tslib"; - interface ReferencePathMatchResult { - fileReference?: FileReference; - diagnosticMessage?: DiagnosticMessage; - isNoDefaultLib?: boolean; - isTypeReferenceDirective?: boolean; - } - function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration; - interface StringSymbolWriter extends SymbolWriter { - string(): string; - } - function getSingleLineStringWriter(): StringSymbolWriter; - function releaseStringWriter(writer: StringSymbolWriter): void; - function getFullWidth(node: Node): number; - function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean; - function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull; - function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void; - function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void; - function moduleResolutionIsEqualTo(oldResolution: ResolvedModuleFull, newResolution: ResolvedModuleFull): boolean; - function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean; - function hasChangesInResolutions(names: string[], newResolutions: T[], oldResolutions: Map, comparer: (oldResolution: T, newResolution: T) => boolean): boolean; - function containsParseError(node: Node): boolean; - function getSourceFileOfNode(node: Node): SourceFile; - function isStatementWithLocals(node: Node): boolean; - function getStartPositionOfLine(line: number, sourceFile: SourceFile): number; - function nodePosToString(node: Node): string; - function getStartPosOfNode(node: Node): number; - function isDefined(value: any): boolean; - function getEndLinePosition(line: number, sourceFile: SourceFile): number; - function nodeIsMissing(node: Node): boolean; - function nodeIsPresent(node: Node): boolean; - function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDoc?: boolean): number; - function isJSDocNode(node: Node): boolean; - function isJSDocTag(node: Node): boolean; - function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number; - function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia?: boolean): string; - function getTextOfNodeFromSourceText(sourceText: string, node: Node): string; - function getTextOfNode(node: Node, includeTrivia?: boolean): string; - function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget): string; - function isBinaryOrOctalIntegerLiteral(node: LiteralLikeNode, text: string): boolean; - function escapeIdentifier(identifier: string): string; - function unescapeIdentifier(identifier: string): string; - function makeIdentifierFromModuleName(moduleName: string): string; - function isBlockOrCatchScoped(declaration: Declaration): boolean; - function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration): boolean; - function isAmbientModule(node: Node): boolean; - function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean; - function isBlockScopedContainerTopLevel(node: Node): boolean; - function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean; - function isExternalModuleAugmentation(node: Node): boolean; - function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions): boolean; - function isBlockScope(node: Node, parentNode: Node): boolean; - function getEnclosingBlockScopeContainer(node: Node): Node; - function declarationNameToString(name: DeclarationName): string; - function getTextOfPropertyName(name: PropertyName): string; - function entityNameToString(name: EntityNameOrEntityNameExpression): string; - function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic; - function createDiagnosticForNodeInSourceFile(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic; - function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic; - function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan; - function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan; - function isExternalOrCommonJsModule(file: SourceFile): boolean; - function isDeclarationFile(file: SourceFile): boolean; - function isConstEnumDeclaration(node: Node): boolean; - function isConst(node: Node): boolean; - function isLet(node: Node): boolean; - function isSuperCall(n: Node): n is SuperCall; - function isPrologueDirective(node: Node): node is PrologueDirective; - function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; - function getLeadingCommentRangesOfNodeFromText(node: Node, text: string): CommentRange[]; - function getJSDocCommentRanges(node: Node, text: string): CommentRange[]; - let fullTripleSlashReferencePathRegEx: RegExp; - let fullTripleSlashReferenceTypeReferenceDirectiveRegEx: RegExp; - let fullTripleSlashAMDReferencePathRegEx: RegExp; - function isPartOfTypeNode(node: Node): boolean; - function isChildOfNodeWithKind(node: Node, kind: SyntaxKind): boolean; - function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression; - function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; - function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void; - function getRestParameterElementType(node: TypeNode): TypeNode; - function isVariableLike(node: Node): node is VariableLikeDeclaration; - function isAccessor(node: Node): node is AccessorDeclaration; - function isClassLike(node: Node): node is ClassLikeDeclaration; - function isFunctionLike(node: Node): node is FunctionLikeDeclaration; - function isFunctionLikeKind(kind: SyntaxKind): boolean; - function introducesArgumentsExoticObject(node: Node): boolean; - function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement; - function unwrapInnermostStatmentOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void): Statement; - function isFunctionBlock(node: Node): boolean; - function isObjectLiteralMethod(node: Node): node is MethodDeclaration; - function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration; - function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate; - function isThisTypePredicate(predicate: TypePredicate): predicate is ThisTypePredicate; - function getContainingFunction(node: Node): FunctionLikeDeclaration; - function getContainingClass(node: Node): ClassLikeDeclaration; - function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; - function getNewTargetContainer(node: Node): Node; - function getSuperContainer(node: Node, stopOnFunctions: boolean): Node; - function getImmediatelyInvokedFunctionExpression(func: Node): CallExpression; - function isSuperProperty(node: Node): node is SuperProperty; - function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression; - function isCallLikeExpression(node: Node): node is CallLikeExpression; - function getInvokedExpression(node: CallLikeExpression): Expression; - function nodeCanBeDecorated(node: Node): boolean; - function nodeIsDecorated(node: Node): boolean; - function nodeOrChildIsDecorated(node: Node): boolean; - function childIsDecorated(node: Node): boolean; - function isJSXTagName(node: Node): boolean; - function isPartOfExpression(node: Node): boolean; - function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; - function isExternalModuleImportEqualsDeclaration(node: Node): boolean; - function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression; - function isInternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isSourceFileJavaScript(file: SourceFile): boolean; - function isInJavaScriptFile(node: Node): boolean; - function isRequireCall(expression: Node, checkArgumentIsStringLiteral: boolean): expression is CallExpression; - function isSingleOrDoubleQuote(charCode: number): boolean; - function isDeclarationOfFunctionExpression(s: Symbol): boolean; - function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind; - function getExternalModuleName(node: Node): Expression; - function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport; - function isDefaultImport(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean; - function hasQuestionToken(node: Node): boolean; - function isJSDocConstructSignature(node: Node): boolean; - function getCommentsFromJSDoc(node: Node): string[]; - function getJSDocParameterTags(param: Node): JSDocParameterTag[]; - function getJSDocType(node: Node): JSDocType; - function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag; - function getJSDocReturnTag(node: Node): JSDocReturnTag; - function getJSDocTemplateTag(node: Node): JSDocTemplateTag; - function hasRestParameter(s: SignatureDeclaration): boolean; - function hasDeclaredRestParameter(s: SignatureDeclaration): boolean; - function isRestParameter(node: ParameterDeclaration): boolean; - function isDeclaredRestParam(node: ParameterDeclaration): boolean; - const enum AssignmentKind { - None = 0, - Definite = 1, - Compound = 2, - } - function getAssignmentTargetKind(node: Node): AssignmentKind; - function isAssignmentTarget(node: Node): boolean; - function isDeleteTarget(node: Node): boolean; - function isNodeDescendantOf(node: Node, ancestor: Node): boolean; - function isInAmbientContext(node: Node): boolean; - function isDeclarationName(name: Node): boolean; - function isLiteralComputedPropertyDeclarationName(node: Node): boolean; - function isIdentifierName(node: Identifier): boolean; - function isAliasSymbolDeclaration(node: Node): boolean; - function exportAssignmentIsAlias(node: ExportAssignment): boolean; - function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments; - function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray; - function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; - function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; - function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile; - function getAncestor(node: Node | undefined, kind: SyntaxKind): Node; - function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult; - function isKeyword(token: SyntaxKind): boolean; - function isTrivia(token: SyntaxKind): boolean; - function isAsyncFunctionLike(node: Node): boolean; - function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral; - function hasDynamicName(declaration: Declaration): boolean; - function isDynamicName(name: DeclarationName): boolean; - function isWellKnownSymbolSyntactically(node: Expression): boolean; - function getPropertyNameForPropertyNameNode(name: DeclarationName | ParameterDeclaration): string; - function getPropertyNameForKnownSymbolName(symbolName: string): string; - function isESSymbolIdentifier(node: Node): boolean; - function isPushOrUnshiftIdentifier(node: Identifier): boolean; - function isModifierKind(token: SyntaxKind): boolean; - function isParameterDeclaration(node: VariableLikeDeclaration): boolean; - function getRootDeclaration(node: Node): Node; - function nodeStartsNewLexicalEnvironment(node: Node): boolean; - function nodeIsSynthesized(node: TextRange): boolean; - function getOriginalNode(node: Node): Node; - function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; - function isParseTreeNode(node: Node): boolean; - function getParseTreeNode(node: Node): Node; - function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; - function getOriginalSourceFiles(sourceFiles: SourceFile[]): SourceFile[]; - function getOriginalNodeId(node: Node): number; - const enum Associativity { - Left = 0, - Right = 1, - } - function getExpressionAssociativity(expression: Expression): Associativity; - function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; - function getExpressionPrecedence(expression: Expression): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.MetaProperty | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.Count; - function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function createDiagnosticCollection(): DiagnosticCollection; - function escapeString(s: string): string; - function isIntrinsicJsxName(name: string): boolean; - function escapeNonAsciiCharacters(s: string): string; - interface EmitTextWriter { - write(s: string): void; - writeTextOfNode(text: string, node: Node): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - getText(): string; - rawWrite(s: string): void; - writeLiteral(s: string): void; - getTextPos(): number; - getLine(): number; - getColumn(): number; - getIndent(): number; - isAtStartOfLine(): boolean; - reset(): void; - } - function getIndentString(level: number): string; - function getIndentSize(): number; - function createTextWriter(newLine: String): EmitTextWriter; - function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string; - function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string; - function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string; - function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; - function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost): string; - interface EmitFileNames { - jsFilePath: string; - sourceMapFilePath: string; - declarationFilePath: string; - } - function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[]; - function filterSourceFilesInDirectory(sourceFiles: SourceFile[], isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): SourceFile[]; - function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, emitOnlyDtsFiles?: boolean): void; - function forEachExpectedEmitFile(host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, targetSourceFile?: SourceFile, emitOnlyDtsFiles?: boolean): void; - function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; - function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: SourceFile[]): void; - function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; - function getLineOfLocalPositionFromLineMap(lineMap: number[], pos: number): number; - function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration; - function getSetAccessorTypeAnnotationNode(accessor: SetAccessorDeclaration): TypeNode; - function getThisParameter(signature: SignatureDeclaration): ParameterDeclaration | undefined; - function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean; - function isThisIdentifier(node: Node | undefined): boolean; - function identifierIsThisKeyword(id: Identifier): boolean; - interface AllAccessorDeclarations { - firstAccessor: AccessorDeclaration; - secondAccessor: AccessorDeclaration; - getAccessor: AccessorDeclaration; - setAccessor: AccessorDeclaration; - } - function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): AllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap: number[], writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, leadingComments: CommentRange[]): void; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, commentPos: number): void; - function emitComments(text: string, lineMap: number[], writer: EmitTextWriter, comments: CommentRange[], leadingSeparator: boolean, trailingSeparator: boolean, newLine: string, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void): void; - function emitDetachedComments(text: string, lineMap: number[], writer: EmitTextWriter, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void, node: TextRange, newLine: string, removeComments: boolean): { - nodePos: number; - detachedCommentEndPos: number; - }; - function writeCommentRange(text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string): void; - function hasModifiers(node: Node): boolean; - function hasModifier(node: Node, flags: ModifierFlags): boolean; - function getModifierFlags(node: Node): ModifierFlags; - function modifierToFlag(token: SyntaxKind): ModifierFlags; - function isLogicalOperator(token: SyntaxKind): boolean; - function isAssignmentOperator(token: SyntaxKind): boolean; - function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined; - function isAssignmentExpression(node: Node, excludeCompoundAssignment: true): node is AssignmentExpression; - function isAssignmentExpression(node: Node, excludeCompoundAssignment?: false): node is AssignmentExpression; - function isDestructuringAssignment(node: Node): node is DestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean; - function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean; - function isEntityNameExpression(node: Expression): node is EntityNameExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean; - function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean; - function getLocalSymbolForExportDefault(symbol: Symbol): Symbol; - function tryExtractTypeScriptExtension(fileName: string): string | undefined; - function convertToBase64(input: string): string; - function getNewLineCharacter(options: CompilerOptions): string; - function isSimpleExpression(node: Expression): boolean; - function formatSyntaxKind(kind: SyntaxKind): string; - function movePos(pos: number, value: number): number; - function createRange(pos: number, end: number): TextRange; - function moveRangeEnd(range: TextRange, end: number): TextRange; - function moveRangePos(range: TextRange, pos: number): TextRange; - function moveRangePastDecorators(node: Node): TextRange; - function moveRangePastModifiers(node: Node): TextRange; - function isCollapsedRange(range: TextRange): boolean; - function collapseRangeToStart(range: TextRange): TextRange; - function collapseRangeToEnd(range: TextRange): TextRange; - function createTokenRange(pos: number, token: SyntaxKind): TextRange; - function rangeIsOnSingleLine(range: TextRange, sourceFile: SourceFile): boolean; - function rangeStartPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeEndPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeStartIsOnSameLineAsRangeEnd(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeEndIsOnSameLineAsRangeStart(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function positionsAreOnSameLine(pos1: number, pos2: number, sourceFile: SourceFile): boolean; - function getStartPositionOfRange(range: TextRange, sourceFile: SourceFile): number; - function isDeclarationNameOfEnumOrNamespace(node: Identifier): boolean; - function getInitializedVariables(node: VariableDeclarationList): VariableDeclaration[]; - function isMergedWithClass(node: Node): boolean; - function isFirstDeclarationOfKind(node: Node, kind: SyntaxKind): boolean; - function isNodeArray(array: T[]): array is NodeArray; - function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression; - function isLiteralKind(kind: SyntaxKind): boolean; - function isTextualLiteralKind(kind: SyntaxKind): boolean; - function isLiteralExpression(node: Node): node is LiteralExpression; - function isTemplateLiteralKind(kind: SyntaxKind): boolean; - function isTemplateHead(node: Node): node is TemplateHead; - function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; - function isIdentifier(node: Node): node is Identifier; - function isVoidExpression(node: Node): node is VoidExpression; - function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier; - function isModifier(node: Node): node is Modifier; - function isQualifiedName(node: Node): node is QualifiedName; - function isComputedPropertyName(node: Node): node is ComputedPropertyName; - function isEntityName(node: Node): node is EntityName; - function isPropertyName(node: Node): node is PropertyName; - function isModuleName(node: Node): node is ModuleName; - function isBindingName(node: Node): node is BindingName; - function isTypeParameter(node: Node): node is TypeParameterDeclaration; - function isParameter(node: Node): node is ParameterDeclaration; - function isDecorator(node: Node): node is Decorator; - function isMethodDeclaration(node: Node): node is MethodDeclaration; - function isClassElement(node: Node): node is ClassElement; - function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike; - function isTypeNode(node: Node): node is TypeNode; - function isArrayBindingPattern(node: Node): node is ArrayBindingPattern; - function isObjectBindingPattern(node: Node): node is ObjectBindingPattern; - function isBindingPattern(node: Node): node is BindingPattern; - function isAssignmentPattern(node: Node): node is AssignmentPattern; - function isBindingElement(node: Node): node is BindingElement; - function isArrayBindingElement(node: Node): node is ArrayBindingElement; - function isDeclarationBindingElement(bindingElement: BindingOrAssignmentElement): bindingElement is VariableDeclaration | ParameterDeclaration | BindingElement; - function isBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is BindingOrAssignmentPattern; - function isObjectBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ObjectBindingOrAssignmentPattern; - function isArrayBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ArrayBindingOrAssignmentPattern; - function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; - function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; - function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; - function isElementAccessExpression(node: Node): node is ElementAccessExpression; - function isBinaryExpression(node: Node): node is BinaryExpression; - function isConditionalExpression(node: Node): node is ConditionalExpression; - function isCallExpression(node: Node): node is CallExpression; - function isTemplateLiteral(node: Node): node is TemplateLiteral; - function isSpreadExpression(node: Node): node is SpreadElement; - function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments; - function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression; - function isUnaryExpression(node: Node): node is UnaryExpression; - function isExpression(node: Node): node is Expression; - function isAssertionExpression(node: Node): node is AssertionExpression; - function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression; - function isNotEmittedStatement(node: Node): node is NotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression; - function isOmittedExpression(node: Node): node is OmittedExpression; - function isTemplateSpan(node: Node): node is TemplateSpan; - function isBlock(node: Node): node is Block; - function isConciseBody(node: Node): node is ConciseBody; - function isFunctionBody(node: Node): node is FunctionBody; - function isForInitializer(node: Node): node is ForInitializer; - function isVariableDeclaration(node: Node): node is VariableDeclaration; - function isVariableDeclarationList(node: Node): node is VariableDeclarationList; - function isCaseBlock(node: Node): node is CaseBlock; - function isModuleBody(node: Node): node is ModuleBody; - function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isImportClause(node: Node): node is ImportClause; - function isNamedImportBindings(node: Node): node is NamedImportBindings; - function isImportSpecifier(node: Node): node is ImportSpecifier; - function isNamedExports(node: Node): node is NamedExports; - function isExportSpecifier(node: Node): node is ExportSpecifier; - function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration; - function isDeclaration(node: Node): node is Declaration; - function isDeclarationStatement(node: Node): node is DeclarationStatement; - function isStatementButNotDeclaration(node: Node): node is Statement; - function isStatement(node: Node): node is Statement; - function isModuleReference(node: Node): node is ModuleReference; - function isJsxOpeningElement(node: Node): node is JsxOpeningElement; - function isJsxClosingElement(node: Node): node is JsxClosingElement; - function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression; - function isJsxChild(node: Node): node is JsxChild; - function isJsxAttributeLike(node: Node): node is JsxAttributeLike; - function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute; - function isJsxAttribute(node: Node): node is JsxAttribute; - function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression; - function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause; - function isHeritageClause(node: Node): node is HeritageClause; - function isCatchClause(node: Node): node is CatchClause; - function isPropertyAssignment(node: Node): node is PropertyAssignment; - function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment; - function isEnumMember(node: Node): node is EnumMember; - function isSourceFile(node: Node): node is SourceFile; - function isWatchSet(options: CompilerOptions): boolean; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -9425,317 +2239,6 @@ declare namespace ts { readFile(fileName: string): string; }, errors?: Diagnostic[]): void; } -declare namespace ts { - function updateNode(updated: T, original: T): T; - function createNodeArray(elements?: T[], location?: TextRange, hasTrailingComma?: boolean): NodeArray; - function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node; - function createSynthesizedNodeArray(elements?: T[]): NodeArray; - function getSynthesizedClone(node: T): T; - function getMutableClone(node: T): T; - function createLiteral(textSource: StringLiteral | NumericLiteral | Identifier, location?: TextRange): StringLiteral; - function createLiteral(value: string, location?: TextRange): StringLiteral; - function createLiteral(value: number, location?: TextRange): NumericLiteral; - function createLiteral(value: boolean, location?: TextRange): BooleanLiteral; - function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression; - function createIdentifier(text: string, location?: TextRange): Identifier; - function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, location?: TextRange): Identifier; - function createLoopVariable(location?: TextRange): Identifier; - function createUniqueName(text: string, location?: TextRange): Identifier; - function getGeneratedNameForNode(node: Node, location?: TextRange): Identifier; - function createToken(token: TKind): Token; - function createSuper(): PrimaryExpression; - function createThis(location?: TextRange): PrimaryExpression; - function createNull(): PrimaryExpression; - function createComputedPropertyName(expression: Expression, location?: TextRange): ComputedPropertyName; - function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; - function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; - function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; - function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; - function createObjectBindingPattern(elements: BindingElement[], location?: TextRange): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; - function createArrayBindingPattern(elements: ArrayBindingElement[], location?: TextRange): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; - function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange): BindingElement; - function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; - function createArrayLiteral(elements?: Expression[], location?: TextRange, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; - function createObjectLiteral(properties?: ObjectLiteralElementLike[], location?: TextRange, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; - function createPropertyAccess(expression: Expression, name: string | Identifier, location?: TextRange, flags?: NodeFlags): PropertyAccessExpression; - function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; - function createElementAccess(expression: Expression, index: number | Expression, location?: TextRange): ElementAccessExpression; - function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; - function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createParen(expression: Expression, location?: TextRange): ParenthesizedExpression; - function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; - function createDelete(expression: Expression, location?: TextRange): DeleteExpression; - function updateDelete(node: DeleteExpression, expression: Expression): Expression; - function createTypeOf(expression: Expression, location?: TextRange): TypeOfExpression; - function updateTypeOf(node: TypeOfExpression, expression: Expression): Expression; - function createVoid(expression: Expression, location?: TextRange): VoidExpression; - function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; - function createAwait(expression: Expression, location?: TextRange): AwaitExpression; - function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; - function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange): PrefixUnaryExpression; - function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; - function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange): PostfixUnaryExpression; - function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; - function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange): BinaryExpression; - function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; - function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression, location?: TextRange): ConditionalExpression; - function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange): ConditionalExpression; - function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; - function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange): YieldExpression; - function updateYield(node: YieldExpression, expression: Expression): YieldExpression; - function createSpread(expression: Expression, location?: TextRange): SpreadElement; - function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; - function createOmittedExpression(location?: TextRange): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression, location?: TextRange): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; - function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange): TemplateSpan; - function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; - function createBlock(statements: Statement[], location?: TextRange, multiLine?: boolean, flags?: NodeFlags): Block; - function updateBlock(node: Block, statements: Statement[]): Block; - function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; - function createVariableDeclarationList(declarations: VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; - function createVariableDeclaration(name: string | BindingPattern | Identifier, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): VariableDeclaration; - function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; - function createEmptyStatement(location: TextRange): EmptyStatement; - function createStatement(expression: Expression, location?: TextRange, flags?: NodeFlags): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; - function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement, location?: TextRange): IfStatement; - function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; - function createDo(statement: Statement, expression: Expression, location?: TextRange): DoStatement; - function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; - function createWhile(expression: Expression, statement: Statement, location?: TextRange): WhileStatement; - function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; - function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement, location?: TextRange): ForStatement; - function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; - function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForInStatement; - function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForOfStatement; - function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function createContinue(label?: Identifier, location?: TextRange): ContinueStatement; - function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; - function createBreak(label?: Identifier, location?: TextRange): BreakStatement; - function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; - function createReturn(expression?: Expression, location?: TextRange): ReturnStatement; - function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; - function createWith(expression: Expression, statement: Statement, location?: TextRange): WithStatement; - function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; - function createSwitch(expression: Expression, caseBlock: CaseBlock, location?: TextRange): SwitchStatement; - function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; - function createLabel(label: string | Identifier, statement: Statement, location?: TextRange): LabeledStatement; - function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; - function createThrow(expression: Expression, location?: TextRange): ThrowStatement; - function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; - function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block, location?: TextRange): TryStatement; - function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; - function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression, location?: TextRange): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; - function createImportClause(name: Identifier, namedBindings: NamedImportBindings, location?: TextRange): ImportClause; - function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; - function createNamespaceImport(name: Identifier, location?: TextRange): NamespaceImport; - function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ImportSpecifier[], location?: TextRange): NamedImports; - function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; - function createImportSpecifier(propertyName: Identifier, name: Identifier, location?: TextRange): ImportSpecifier; - function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression, location?: TextRange): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression, location?: TextRange): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; - function createNamedExports(elements: ExportSpecifier[], location?: TextRange): NamedExports; - function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; - function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier, location?: TextRange): ExportSpecifier; - function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; - function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement, location?: TextRange): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxOpeningElement; - function createJsxClosingElement(tagName: JsxTagNameExpression, location?: TextRange): JsxClosingElement; - function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression, location?: TextRange): JsxAttribute; - function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxSpreadAttribute(expression: Expression, location?: TextRange): JsxSpreadAttribute; - function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; - function createJsxExpression(expression: Expression, dotDotDotToken: Token, location?: TextRange): JsxExpression; - function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; - function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[], location?: TextRange): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; - function createCaseClause(expression: Expression, statements: Statement[], location?: TextRange): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; - function createDefaultClause(statements: Statement[], location?: TextRange): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; - function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block, location?: TextRange): CatchClause; - function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; - function createPropertyAssignment(name: string | PropertyName, initializer: Expression, location?: TextRange): PropertyAssignment; - function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; - function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression, location?: TextRange): ShorthandPropertyAssignment; - function createSpreadAssignment(expression: Expression, location?: TextRange): SpreadAssignment; - function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; - function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; - function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; - function createNotEmittedStatement(original: Node): NotEmittedStatement; - function createEndOfDeclarationMarker(original: Node): EndOfDeclarationMarker; - function createMergeDeclarationMarker(original: Node): MergeDeclarationMarker; - function createPartiallyEmittedExpression(expression: Expression, original?: Node, location?: TextRange): PartiallyEmittedExpression; - function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createComma(left: Expression, right: Expression): Expression; - function createLessThan(left: Expression, right: Expression, location?: TextRange): Expression; - function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression, location?: TextRange): DestructuringAssignment; - function createAssignment(left: Expression, right: Expression, location?: TextRange): BinaryExpression; - function createStrictEquality(left: Expression, right: Expression): BinaryExpression; - function createStrictInequality(left: Expression, right: Expression): BinaryExpression; - function createAdd(left: Expression, right: Expression): BinaryExpression; - function createSubtract(left: Expression, right: Expression): BinaryExpression; - function createPostfixIncrement(operand: Expression, location?: TextRange): PostfixUnaryExpression; - function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; - function createLogicalOr(left: Expression, right: Expression): BinaryExpression; - function createLogicalNot(operand: Expression): PrefixUnaryExpression; - function createVoidZero(): VoidExpression; - type TypeOfTag = "undefined" | "number" | "boolean" | "string" | "symbol" | "object" | "function"; - function createTypeCheck(value: Expression, tag: TypeOfTag): BinaryExpression; - function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression; - function createFunctionCall(func: Expression, thisArg: Expression, argumentsList: Expression[], location?: TextRange): CallExpression; - function createFunctionApply(func: Expression, thisArg: Expression, argumentsExpression: Expression, location?: TextRange): CallExpression; - function createArraySlice(array: Expression, start?: number | Expression): CallExpression; - function createArrayConcat(array: Expression, values: Expression[]): CallExpression; - function createMathPow(left: Expression, right: Expression, location?: TextRange): CallExpression; - function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression; - function createExportDefault(expression: Expression): ExportAssignment; - function createExternalModuleExport(exportName: Identifier): ExportDeclaration; - function createLetStatement(name: Identifier, initializer: Expression, location?: TextRange): VariableStatement; - function createLetDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function createConstDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function getHelperName(name: string): Identifier; - function restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement; - interface CallBinding { - target: LeftHandSideExpression; - thisArg: Expression; - } - function createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding; - function inlineExpressions(expressions: Expression[]): Expression; - function createExpressionFromEntityName(node: EntityName | Expression): Expression; - function createExpressionForPropertyName(memberName: PropertyName): Expression; - function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression; - function getLocalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function isLocalName(node: Identifier): boolean; - function getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function isExportName(node: Identifier): boolean; - function getDeclarationName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression; - function getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression; - function convertToFunctionBody(node: ConciseBody, multiLine?: boolean): Block; - function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; - function startsWithUseStrict(statements: Statement[]): boolean; - function ensureUseStrict(statements: NodeArray): NodeArray; - function parenthesizeBinaryOperand(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand?: Expression): Expression; - function parenthesizeForConditionalHead(condition: Expression): Expression; - function parenthesizeForNew(expression: Expression): LeftHandSideExpression; - function parenthesizeForAccess(expression: Expression): LeftHandSideExpression; - function parenthesizePostfixOperand(operand: Expression): LeftHandSideExpression; - function parenthesizePrefixOperand(operand: Expression): UnaryExpression; - function parenthesizeExpressionForList(expression: Expression): Expression; - function parenthesizeExpressionForExpressionStatement(expression: Expression): Expression; - function parenthesizeConciseBody(body: ConciseBody): ConciseBody; - const enum OuterExpressionKinds { - Parentheses = 1, - Assertions = 2, - PartiallyEmittedExpressions = 4, - All = 7, - } - function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; - function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node; - function skipParentheses(node: Expression): Expression; - function skipParentheses(node: Node): Node; - function skipAssertions(node: Expression): Expression; - function skipAssertions(node: Node): Node; - function skipPartiallyEmittedExpressions(node: Expression): Expression; - function skipPartiallyEmittedExpressions(node: Node): Node; - function startOnNewLine(node: T): T; - function setOriginalNode(node: T, original: Node): T; - function disposeEmitNodes(sourceFile: SourceFile): void; - function getOrCreateEmitNode(node: Node): EmitNode; - function getEmitFlags(node: Node): EmitFlags; - function setEmitFlags(node: T, emitFlags: EmitFlags): T; - function getSourceMapRange(node: Node): TextRange; - function setSourceMapRange(node: T, range: TextRange): T; - function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; - function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; - function getCommentRange(node: Node): TextRange; - function setCommentRange(node: T, range: TextRange): T; - function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; - function getExternalHelpersModuleName(node: SourceFile): Identifier; - function getOrCreateExternalHelpersModuleNameIfNeeded(node: SourceFile, compilerOptions: CompilerOptions): Identifier; - function addEmitHelper(node: T, helper: EmitHelper): T; - function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T; - function removeEmitHelper(node: Node, helper: EmitHelper): boolean; - function getEmitHelpers(node: Node): EmitHelper[] | undefined; - function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; - function compareEmitHelpers(x: EmitHelper, y: EmitHelper): Comparison; - function setTextRange(node: T, location: TextRange): T; - function setNodeFlags(node: T, flags: NodeFlags): T; - function setMultiLine(node: T, multiLine: boolean): T; - function setHasTrailingComma(nodes: NodeArray, hasTrailingComma: boolean): NodeArray; - function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile): Identifier; - function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions): StringLiteral; - function tryGetModuleNameFromFile(file: SourceFile, host: EmitHost, options: CompilerOptions): StringLiteral; - function getInitializerOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): Expression | undefined; - function getTargetOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementTarget; - function getRestIndicatorOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementRestIndicator; - function getPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): PropertyName; - function getElementsOfBindingOrAssignmentPattern(name: BindingOrAssignmentPattern): BindingOrAssignmentElement[]; - function convertToArrayAssignmentElement(element: BindingOrAssignmentElement): Expression; - function convertToObjectAssignmentElement(element: BindingOrAssignmentElement): ObjectLiteralElementLike; - function convertToAssignmentPattern(node: BindingOrAssignmentPattern): AssignmentPattern; - function convertToObjectAssignmentPattern(node: ObjectBindingOrAssignmentPattern): ObjectLiteralExpression; - function convertToArrayAssignmentPattern(node: ArrayBindingOrAssignmentPattern): ArrayLiteralExpression; - function convertToAssignmentElementTarget(node: BindingOrAssignmentElementTarget): Expression; - interface ExternalModuleInfo { - externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; - externalHelpersImportDeclaration: ImportDeclaration | undefined; - exportSpecifiers: Map; - exportedBindings: Map; - exportedNames: Identifier[]; - exportEquals: ExportAssignment | undefined; - hasExportStarsToExportValues: boolean; - } - function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo; -} declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; @@ -9743,140 +2246,10 @@ declare namespace ts { function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; function isExternalModule(file: SourceFile): boolean; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function parseIsolatedJSDocComment(content: string, start?: number, length?: number): { - jsDoc: JSDoc; - diagnostics: Diagnostic[]; - }; - function parseJSDocTypeExpressionForTests(content: string, start?: number, length?: number): { - jsDocTypeExpression: JSDocTypeExpression; - diagnostics: Diagnostic[]; - }; -} -declare namespace ts { - const enum ModuleInstanceState { - NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2, - } - function getModuleInstanceState(node: Node): ModuleInstanceState; - function bindSourceFile(file: SourceFile, options: CompilerOptions): void; - function computeTransformFlagsForNode(node: Node, subtreeFlags: TransformFlags): TransformFlags; - function getTransformFlagsSubtreeExclusions(kind: SyntaxKind): TransformFlags; -} -declare namespace ts { - function getNodeId(node: Node): number; - function getSymbolId(symbol: Symbol): number; - function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker; -} -declare namespace ts { - type VisitResult = T | T[]; - function reduceEachChild(node: Node, initial: T, cbNode: (memo: T, node: Node) => T, cbNodeArray?: (memo: T, nodes: Node[]) => T): T; - function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional?: boolean, lift?: (node: NodeArray) => T): T; - function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional: boolean, lift: (node: NodeArray) => T, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): T; - function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start?: number, count?: number): NodeArray; - function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start: number, count: number, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): NodeArray; - function visitLexicalEnvironment(statements: NodeArray, visitor: (node: Node) => VisitResult, context: TransformationContext, start?: number, ensureUseStrict?: boolean): NodeArray; - function visitParameterList(nodes: NodeArray, visitor: (node: Node) => VisitResult, context: TransformationContext): NodeArray; - function visitFunctionBody(node: FunctionBody, visitor: (node: Node) => VisitResult, context: TransformationContext): FunctionBody; - function visitFunctionBody(node: ConciseBody, visitor: (node: Node) => VisitResult, context: TransformationContext): ConciseBody; - function visitEachChild(node: T, visitor: (node: Node) => VisitResult, context: TransformationContext): T; - function mergeLexicalEnvironment(statements: NodeArray, declarations: Statement[]): NodeArray; - function mergeLexicalEnvironment(statements: Statement[], declarations: Statement[]): Statement[]; - function mergeFunctionBodyLexicalEnvironment(body: FunctionBody, declarations: Statement[]): FunctionBody; - function mergeFunctionBodyLexicalEnvironment(body: ConciseBody, declarations: Statement[]): ConciseBody; - function liftToBlock(nodes: Node[]): Statement; - function aggregateTransformFlags(node: T): T; - namespace Debug { - const failNotOptional: typeof noop; - const failBadSyntaxKind: (node: Node, message?: string) => void; - const assertEachNode: (nodes: Node[], test: (node: Node) => boolean, message?: string) => void; - const assertNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; - const assertOptionalNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; - const assertOptionalToken: (node: Node, kind: SyntaxKind, message?: string) => void; - const assertMissingNode: (node: Node, message?: string) => void; - } -} -declare namespace ts { - const enum FlattenLevel { - All = 0, - ObjectRest = 1, - } - function flattenDestructuringAssignment(node: VariableDeclaration | DestructuringAssignment, visitor: ((node: Node) => VisitResult) | undefined, context: TransformationContext, level: FlattenLevel, needsValue?: boolean, createAssignmentCallback?: (name: Identifier, value: Expression, location?: TextRange) => Expression): Expression; - function flattenDestructuringBinding(node: VariableDeclaration | ParameterDeclaration, visitor: (node: Node) => VisitResult, context: TransformationContext, level: FlattenLevel, rval?: Expression, hoistTempVariables?: boolean, skipInitializer?: boolean): VariableDeclaration[]; -} -declare namespace ts { - function transformTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformESNext(context: TransformationContext): (node: SourceFile) => SourceFile; - function createAssignHelper(context: TransformationContext, attributesSegments: Expression[]): CallExpression; -} -declare namespace ts { - function transformJsx(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2017(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2016(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2015(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformGenerators(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES5(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformModule(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformSystemModule(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2015Module(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function getTransformers(compilerOptions: CompilerOptions): Transformer[]; - function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]): TransformationResult; -} -declare namespace ts { - function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[]; - function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, emitOnlyDtsFiles: boolean): boolean; -} -declare namespace ts { - interface SourceMapWriter { - initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean): void; - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - emitPos(pos: number): void; - emitNodeWithSourceMap(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitTokenWithSourceMap(node: Node, token: SyntaxKind, tokenStartPos: number, emitCallback: (token: SyntaxKind, tokenStartPos: number) => number): number; - getText(): string; - getSourceMappingURL(): string; - getSourceMapData(): SourceMapData; - } - function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter): SourceMapWriter; -} -declare namespace ts { - interface CommentWriter { - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - emitNodeWithComments(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void; - emitTrailingCommentsOfPosition(pos: number): void; - } - function createCommentWriter(host: EmitHost, writer: EmitTextWriter, sourceMap: SourceMapWriter): CommentWriter; -} -declare namespace ts { - function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; interface FormatDiagnosticsHost { @@ -9887,7 +2260,6 @@ declare namespace ts { function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; - function getResolutionDiagnostic(options: CompilerOptions, {extension}: ResolvedModuleFull): DiagnosticMessage | undefined; } declare namespace ts { interface Node { @@ -9933,10 +2305,6 @@ declare namespace ts { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; - getNamedDeclarations(): Map; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; getLineStarts(): number[]; @@ -10027,8 +2395,6 @@ declare namespace ts { getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; - getNonBoundSourceFile(fileName: string): SourceFile; - getSourceFile(fileName: string): SourceFile; dispose(): void; } interface Classifications { @@ -10424,124 +2790,8 @@ declare namespace ts { jsxAttributeStringLiteralValue = 24, } } -declare namespace ts { - const scanner: Scanner; - const emptyArray: any[]; - const enum SemanticMeaning { - None = 0, - Value = 1, - Type = 2, - Namespace = 4, - All = 7, - } - function getMeaningFromDeclaration(node: Node): SemanticMeaning; - function getMeaningFromLocation(node: Node): SemanticMeaning; - function isCallExpressionTarget(node: Node): boolean; - function isNewExpressionTarget(node: Node): boolean; - function climbPastPropertyAccess(node: Node): Node; - function getTargetLabel(referenceNode: Node, labelName: string): Identifier; - function isJumpStatementTarget(node: Node): boolean; - function isLabelName(node: Node): boolean; - function isRightSideOfQualifiedName(node: Node): boolean; - function isRightSideOfPropertyAccess(node: Node): boolean; - function isNameOfModuleDeclaration(node: Node): boolean; - function isNameOfFunctionDeclaration(node: Node): boolean; - function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean; - function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node): boolean; - function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean; - function getContainerNode(node: Node): Declaration; - function getNodeKind(node: Node): string; - function getStringLiteralTypeForNode(node: StringLiteral | LiteralTypeNode, typeChecker: TypeChecker): LiteralType; - function isThis(node: Node): boolean; - interface ListItemInfo { - listItemIndex: number; - list: Node; - } - function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; - function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; - function startEndContainsRange(start: number, end: number, range: TextRange): boolean; - function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; - function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; - function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; - function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; - function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; - function findListItemInfo(node: Node): ListItemInfo; - function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; - function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; - function findContainingList(node: Node): Node; - function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; - function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; - function findNextToken(previousToken: Node, parent: Node): Node; - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; - function isInString(sourceFile: SourceFile, position: number): boolean; - function isInComment(sourceFile: SourceFile, position: number): boolean; - function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; - function isInTemplateString(sourceFile: SourceFile, position: number): boolean; - function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean; - function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; - function getNodeModifiers(node: Node): string; - function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; - function isToken(n: Node): boolean; - function isWord(kind: SyntaxKind): boolean; - function isComment(kind: SyntaxKind): boolean; - function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; - function isPunctuation(kind: SyntaxKind): boolean; - function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; - function isAccessibilityModifier(kind: SyntaxKind): boolean; - function compareDataObjects(dst: any, src: any): boolean; - function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; - function hasTrailingDirectorySeparator(path: string): boolean; - function isInReferenceComment(sourceFile: SourceFile, position: number): boolean; - function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean; -} -declare namespace ts { - function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; - function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; - function displayPart(text: string, kind: SymbolDisplayPartKind): SymbolDisplayPart; - function spacePart(): SymbolDisplayPart; - function keywordPart(kind: SyntaxKind): SymbolDisplayPart; - function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; - function operatorPart(kind: SyntaxKind): SymbolDisplayPart; - function textOrKeywordPart(text: string): SymbolDisplayPart; - function textPart(text: string): SymbolDisplayPart; - function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; - function lineBreakPart(): SymbolDisplayPart; - function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; - function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; - function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function isImportOrExportSpecifierName(location: Node): boolean; - function stripQuotes(name: string): string; - function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; - function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; - function sanitizeConfigFile(configFileName: string, content: string): { - configJsonObject: any; - diagnostics: Diagnostic[]; - }; - function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile): number; -} -declare namespace ts.BreakpointResolver { - function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number): TextSpan; -} declare namespace ts { function createClassifier(): Classifier; - function getSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): ClassifiedSpan[]; - function getEncodedSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): Classifications; - function getSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): ClassifiedSpan[]; - function getEncodedSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): Classifications; -} -declare namespace ts.Completions { - function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo; - function getCompletionEntryDetails(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): CompletionEntryDetails; - function getCompletionEntrySymbol(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): Symbol; -} -declare namespace ts.DocumentHighlights { - function getDocumentHighlights(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[]; } declare namespace ts { interface DocumentRegistry { @@ -10559,88 +2809,9 @@ declare namespace ts { }; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; } -declare namespace ts.FindAllReferences { - function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[]; - function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[]; - function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[]; - function getReferenceEntriesForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker, result: ReferenceEntry[]): void; - function getReferenceEntryFromNode(node: Node): ReferenceEntry; -} -declare namespace ts.GoToDefinition { - function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[]; - function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): DefinitionInfo[]; -} -declare namespace ts.GoToImplementation { - function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[]; -} -declare namespace ts.JsDoc { - function getJsDocCommentsFromDeclarations(declarations: Declaration[]): SymbolDisplayPart[]; - function getAllJsDocCompletionEntries(): CompletionEntry[]; - function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion; -} -declare namespace ts.NavigateTo { - function getNavigateToItems(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[]; -} -declare namespace ts.NavigationBar { - function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[]; - function getNavigationTree(sourceFile: SourceFile): NavigationTree; -} -declare namespace ts.OutliningElementsCollector { - function collectElements(sourceFile: SourceFile): OutliningSpan[]; -} -declare namespace ts { - enum PatternMatchKind { - exact = 0, - prefix = 1, - substring = 2, - camelCase = 3, - } - interface PatternMatch { - kind: PatternMatchKind; - camelCaseWeight?: number; - isCaseSensitive: boolean; - punctuationStripped: boolean; - } - interface PatternMatcher { - getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[]; - getMatches(candidateContainers: string[], candidate: string): PatternMatch[]; - patternContainsDots: boolean; - } - function createPatternMatcher(pattern: string): PatternMatcher; - function breakIntoCharacterSpans(identifier: string): TextSpan[]; - function breakIntoWordSpans(identifier: string): TextSpan[]; -} declare namespace ts { function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; } -declare namespace ts.Rename { - function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo; -} -declare namespace ts.SignatureHelp { - const enum ArgumentListKind { - TypeArguments = 0, - CallArguments = 1, - TaggedTemplateArguments = 2, - } - interface ArgumentListInfo { - kind: ArgumentListKind; - invocation: CallLikeExpression; - argumentsSpan: TextSpan; - argumentIndex?: number; - argumentCount: number; - } - function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems; - function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo; -} -declare namespace ts.SymbolDisplay { - function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function getSymbolModifiers(symbol: Symbol): string; - function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node, location: Node, semanticMeaning?: SemanticMeaning): { - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - symbolKind: string; - }; -} declare namespace ts { interface TranspileOptions { compilerOptions?: CompilerOptions; @@ -10657,460 +2828,11 @@ declare namespace ts { function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; } -declare namespace ts.formatting { - interface FormattingScanner { - advance(): void; - isOnToken(): boolean; - readTokenInfo(n: Node): TokenInfo; - getCurrentLeadingTrivia(): TextRangeWithKind[]; - lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; - close(): void; - } - function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; -} -declare namespace ts.formatting { - class FormattingContext { - sourceFile: SourceFile; - formattingRequestKind: FormattingRequestKind; - currentTokenSpan: TextRangeWithKind; - nextTokenSpan: TextRangeWithKind; - contextNode: Node; - currentTokenParent: Node; - nextTokenParent: Node; - private contextNodeAllOnSameLine; - private nextNodeAllOnSameLine; - private tokensAreOnSameLine; - private contextNodeBlockIsOnOneLine; - private nextNodeBlockIsOnOneLine; - constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); - updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; - ContextNodeAllOnSameLine(): boolean; - NextNodeAllOnSameLine(): boolean; - TokensAreOnSameLine(): boolean; - ContextNodeBlockIsOnOneLine(): boolean; - NextNodeBlockIsOnOneLine(): boolean; - private NodeIsOnOneLine(node); - private BlockIsOnOneLine(node); - } -} -declare namespace ts.formatting { - const enum FormattingRequestKind { - FormatDocument = 0, - FormatSelection = 1, - FormatOnEnter = 2, - FormatOnSemicolon = 3, - FormatOnClosingCurlyBrace = 4, - } -} -declare namespace ts.formatting { - class Rule { - Descriptor: RuleDescriptor; - Operation: RuleOperation; - Flag: RuleFlags; - constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); - toString(): string; - } -} -declare namespace ts.formatting { - const enum RuleAction { - Ignore = 1, - Space = 2, - NewLine = 4, - Delete = 8, - } -} -declare namespace ts.formatting { - class RuleDescriptor { - LeftTokenRange: Shared.TokenRange; - RightTokenRange: Shared.TokenRange; - constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); - toString(): string; - static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; - static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; - static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; - static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; - } -} -declare namespace ts.formatting { - const enum RuleFlags { - None = 0, - CanDeleteNewLines = 1, - } -} -declare namespace ts.formatting { - class RuleOperation { - Context: RuleOperationContext; - Action: RuleAction; - constructor(Context: RuleOperationContext, Action: RuleAction); - toString(): string; - static create1(action: RuleAction): RuleOperation; - static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; - } -} -declare namespace ts.formatting { - class RuleOperationContext { - private customContextChecks; - constructor(...funcs: { - (context: FormattingContext): boolean; - }[]); - static Any: RuleOperationContext; - IsAny(): boolean; - InContext(context: FormattingContext): boolean; - } -} -declare namespace ts.formatting { - class Rules { - getRuleName(rule: Rule): string; - [name: string]: any; - IgnoreBeforeComment: Rule; - IgnoreAfterLineComment: Rule; - NoSpaceBeforeSemicolon: Rule; - NoSpaceBeforeColon: Rule; - NoSpaceBeforeQuestionMark: Rule; - SpaceAfterColon: Rule; - SpaceAfterQuestionMarkInConditionalOperator: Rule; - NoSpaceAfterQuestionMark: Rule; - SpaceAfterSemicolon: Rule; - SpaceAfterCloseBrace: Rule; - SpaceBetweenCloseBraceAndElse: Rule; - SpaceBetweenCloseBraceAndWhile: Rule; - NoSpaceAfterCloseBrace: Rule; - NoSpaceBeforeDot: Rule; - NoSpaceAfterDot: Rule; - NoSpaceBeforeOpenBracket: Rule; - NoSpaceAfterCloseBracket: Rule; - SpaceAfterOpenBrace: Rule; - SpaceBeforeCloseBrace: Rule; - NoSpaceAfterOpenBrace: Rule; - NoSpaceBeforeCloseBrace: Rule; - NoSpaceBetweenEmptyBraceBrackets: Rule; - NewLineAfterOpenBraceInBlockContext: Rule; - NewLineBeforeCloseBraceInBlockContext: Rule; - NoSpaceAfterUnaryPrefixOperator: Rule; - NoSpaceAfterUnaryPreincrementOperator: Rule; - NoSpaceAfterUnaryPredecrementOperator: Rule; - NoSpaceBeforeUnaryPostincrementOperator: Rule; - NoSpaceBeforeUnaryPostdecrementOperator: Rule; - SpaceAfterPostincrementWhenFollowedByAdd: Rule; - SpaceAfterAddWhenFollowedByUnaryPlus: Rule; - SpaceAfterAddWhenFollowedByPreincrement: Rule; - SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; - SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; - SpaceAfterSubtractWhenFollowedByPredecrement: Rule; - NoSpaceBeforeComma: Rule; - SpaceAfterCertainKeywords: Rule; - SpaceAfterLetConstInVariableDeclaration: Rule; - NoSpaceBeforeOpenParenInFuncCall: Rule; - SpaceAfterFunctionInFuncDecl: Rule; - SpaceBeforeOpenParenInFuncDecl: Rule; - NoSpaceBeforeOpenParenInFuncDecl: Rule; - SpaceAfterVoidOperator: Rule; - NoSpaceBetweenReturnAndSemicolon: Rule; - SpaceBetweenStatements: Rule; - SpaceAfterTryFinally: Rule; - SpaceAfterGetSetInMember: Rule; - SpaceBeforeBinaryKeywordOperator: Rule; - SpaceAfterBinaryKeywordOperator: Rule; - SpaceAfterConstructor: Rule; - NoSpaceAfterConstructor: Rule; - NoSpaceAfterModuleImport: Rule; - SpaceAfterCertainTypeScriptKeywords: Rule; - SpaceBeforeCertainTypeScriptKeywords: Rule; - SpaceAfterModuleName: Rule; - SpaceBeforeArrow: Rule; - SpaceAfterArrow: Rule; - NoSpaceAfterEllipsis: Rule; - NoSpaceAfterOptionalParameters: Rule; - NoSpaceBeforeOpenAngularBracket: Rule; - NoSpaceBetweenCloseParenAndAngularBracket: Rule; - NoSpaceAfterOpenAngularBracket: Rule; - NoSpaceBeforeCloseAngularBracket: Rule; - NoSpaceAfterCloseAngularBracket: Rule; - NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; - HighPriorityCommonRules: Rule[]; - LowPriorityCommonRules: Rule[]; - SpaceAfterComma: Rule; - NoSpaceAfterComma: Rule; - SpaceBeforeBinaryOperator: Rule; - SpaceAfterBinaryOperator: Rule; - NoSpaceBeforeBinaryOperator: Rule; - NoSpaceAfterBinaryOperator: Rule; - SpaceAfterKeywordInControl: Rule; - NoSpaceAfterKeywordInControl: Rule; - FunctionOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInFunction: Rule; - NewLineBeforeOpenBraceInFunction: Rule; - TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - ControlOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInControl: Rule; - NewLineBeforeOpenBraceInControl: Rule; - SpaceAfterSemicolonInFor: Rule; - NoSpaceAfterSemicolonInFor: Rule; - SpaceAfterOpenParen: Rule; - SpaceBeforeCloseParen: Rule; - NoSpaceBetweenParens: Rule; - NoSpaceAfterOpenParen: Rule; - NoSpaceBeforeCloseParen: Rule; - SpaceAfterOpenBracket: Rule; - SpaceBeforeCloseBracket: Rule; - NoSpaceBetweenBrackets: Rule; - NoSpaceAfterOpenBracket: Rule; - NoSpaceBeforeCloseBracket: Rule; - SpaceAfterAnonymousFunctionKeyword: Rule; - NoSpaceAfterAnonymousFunctionKeyword: Rule; - SpaceBeforeAt: Rule; - NoSpaceAfterAt: Rule; - SpaceAfterDecorator: Rule; - NoSpaceBetweenFunctionKeywordAndStar: Rule; - SpaceAfterStarInGeneratorDeclaration: Rule; - NoSpaceBetweenYieldKeywordAndStar: Rule; - SpaceBetweenYieldOrYieldStarAndOperand: Rule; - SpaceBetweenAsyncAndOpenParen: Rule; - SpaceBetweenAsyncAndFunctionKeyword: Rule; - NoSpaceBetweenTagAndTemplateString: Rule; - NoSpaceAfterTemplateHeadAndMiddle: Rule; - SpaceAfterTemplateHeadAndMiddle: Rule; - NoSpaceBeforeTemplateMiddleAndTail: Rule; - SpaceBeforeTemplateMiddleAndTail: Rule; - NoSpaceAfterOpenBraceInJsxExpression: Rule; - SpaceAfterOpenBraceInJsxExpression: Rule; - NoSpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeJsxAttribute: Rule; - SpaceBeforeSlashInJsxOpeningElement: Rule; - NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; - NoSpaceBeforeEqualInJsxAttribute: Rule; - NoSpaceAfterEqualInJsxAttribute: Rule; - NoSpaceAfterTypeAssertion: Rule; - SpaceAfterTypeAssertion: Rule; - NoSpaceBeforeNonNullAssertionOperator: Rule; - constructor(); - static IsForContext(context: FormattingContext): boolean; - static IsNotForContext(context: FormattingContext): boolean; - static IsBinaryOpContext(context: FormattingContext): boolean; - static IsNotBinaryOpContext(context: FormattingContext): boolean; - static IsConditionalOperatorContext(context: FormattingContext): boolean; - static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsBraceWrappedContext(context: FormattingContext): boolean; - static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsMultilineBlockContext(context: FormattingContext): boolean; - static IsSingleLineBlockContext(context: FormattingContext): boolean; - static IsBlockContext(context: FormattingContext): boolean; - static IsBeforeBlockContext(context: FormattingContext): boolean; - static NodeIsBlockContext(node: Node): boolean; - static IsFunctionDeclContext(context: FormattingContext): boolean; - static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; - static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; - static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; - static IsAfterCodeBlockContext(context: FormattingContext): boolean; - static IsControlDeclContext(context: FormattingContext): boolean; - static IsObjectContext(context: FormattingContext): boolean; - static IsFunctionCallContext(context: FormattingContext): boolean; - static IsNewContext(context: FormattingContext): boolean; - static IsFunctionCallOrNewContext(context: FormattingContext): boolean; - static IsPreviousTokenNotComma(context: FormattingContext): boolean; - static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; - static IsArrowFunctionContext(context: FormattingContext): boolean; - static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; - static IsNonJsxElementContext(context: FormattingContext): boolean; - static IsJsxExpressionContext(context: FormattingContext): boolean; - static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; - static IsJsxAttributeContext(context: FormattingContext): boolean; - static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; - static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; - static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; - static NodeIsInDecoratorContext(node: Node): boolean; - static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; - static IsNotFormatOnEnter(context: FormattingContext): boolean; - static IsModuleDeclContext(context: FormattingContext): boolean; - static IsObjectTypeContext(context: FormattingContext): boolean; - static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; - static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; - static IsTypeAssertionContext(context: FormattingContext): boolean; - static IsVoidOpContext(context: FormattingContext): boolean; - static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; - static IsNonNullAssertionContext(context: FormattingContext): boolean; - } -} -declare namespace ts.formatting { - class RulesMap { - map: RulesBucket[]; - mapRowLength: number; - constructor(); - static create(rules: Rule[]): RulesMap; - Initialize(rules: Rule[]): RulesBucket[]; - FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; - private GetRuleBucketIndex(row, column); - private FillRule(rule, rulesBucketConstructionStateList); - GetRule(context: FormattingContext): Rule; - } - enum RulesPosition { - IgnoreRulesSpecific = 0, - IgnoreRulesAny, - ContextRulesSpecific, - ContextRulesAny, - NoContextRulesSpecific, - NoContextRulesAny, - } - class RulesBucketConstructionState { - private rulesInsertionIndexBitmap; - constructor(); - GetInsertionIndex(maskPosition: RulesPosition): number; - IncreaseInsertionIndex(maskPosition: RulesPosition): void; - } - class RulesBucket { - private rules; - constructor(); - Rules(): Rule[]; - AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; - } -} -declare namespace ts.formatting { - namespace Shared { - interface ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenRangeAccess implements ITokenAccess { - private tokens; - constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenValuesAccess implements ITokenAccess { - private tokens; - constructor(tks: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenSingleValueAccess implements ITokenAccess { - token: SyntaxKind; - constructor(token: SyntaxKind); - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - } - class TokenAllAccess implements ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(): boolean; - toString(): string; - } - class TokenRange { - tokenAccess: ITokenAccess; - constructor(tokenAccess: ITokenAccess); - static FromToken(token: SyntaxKind): TokenRange; - static FromTokens(tokens: SyntaxKind[]): TokenRange; - static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; - static AllTokens(): TokenRange; - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - toString(): string; - static Any: TokenRange; - static AnyIncludingMultilineComments: TokenRange; - static Keywords: TokenRange; - static BinaryOperators: TokenRange; - static BinaryKeywordOperators: TokenRange; - static UnaryPrefixOperators: TokenRange; - static UnaryPrefixExpressions: TokenRange; - static UnaryPreincrementExpressions: TokenRange; - static UnaryPostincrementExpressions: TokenRange; - static UnaryPredecrementExpressions: TokenRange; - static UnaryPostdecrementExpressions: TokenRange; - static Comments: TokenRange; - static TypeNames: TokenRange; - } - } -} -declare namespace ts.formatting { - class RulesProvider { - private globalRules; - private options; - private activeRules; - private rulesMap; - constructor(); - getRuleName(rule: Rule): string; - getRuleByName(name: string): Rule; - getRulesMap(): RulesMap; - ensureUpToDate(options: ts.FormatCodeSettings): void; - private createActiveRules(options); - } -} -declare namespace ts.formatting { - interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; - } - interface TokenInfo { - leadingTrivia: TextRangeWithKind[]; - token: TextRangeWithKind; - trailingTrivia: TextRangeWithKind[]; - } - function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function getIndentationString(indentation: number, options: EditorSettings): string; -} -declare namespace ts.formatting { - namespace SmartIndenter { - function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number; - function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number; - function getBaseIndentation(options: EditorSettings): number; - function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; - function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): { - column: number; - character: number; - }; - function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number; - function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; - function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; - } -} -declare namespace ts { - interface CodeFix { - errorCodes: number[]; - getCodeActions(context: CodeFixContext): CodeAction[] | undefined; - } - interface CodeFixContext { - errorCode: number; - sourceFile: SourceFile; - span: TextSpan; - program: Program; - newLineCharacter: string; - host: LanguageServiceHost; - cancellationToken: CancellationToken; - } - namespace codefix { - function registerCodeFix(action: CodeFix): void; - function getSupportedErrorCodes(): string[]; - function getFixes(context: CodeFixContext): CodeAction[]; - } -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { - function getMissingMembersInsertion(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker, newlineChar: string): string; -} declare namespace ts { const servicesVersion = "0.5"; interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } - function toEditorSettings(options: FormatCodeOptions | FormatCodeSettings): FormatCodeSettings; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; @@ -11119,601 +2841,965 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; - function getNameTable(sourceFile: SourceFile): Map; function getDefaultLibFilePath(options: CompilerOptions): string; } -declare namespace ts.server { - class TextStorage { - private readonly host; - private readonly fileName; - private svc; - private svcVersion; - private text; - private lineMap; - private textVersion; - constructor(host: ServerHost, fileName: NormalizedPath); - getVersion(): string; - hasScriptVersionCache(): boolean; - useScriptVersionCache(newText?: string): void; - useText(newText?: string): void; - edit(start: number, end: number, newText: string): void; - reload(text: string): void; - reloadFromFile(tempFileName?: string): void; - getSnapshot(): IScriptSnapshot; - getLineInfo(line: number): ILineInfo; - lineToTextSpan(line: number): TextSpan; - lineOffsetToPosition(line: number, offset: number): number; - positionToLineOffset(position: number): ILineInfo; - private getFileText(tempFileName?); - private ensureNoScriptVersionCache(); - private switchToScriptVersionCache(newText?); - private getOrLoadText(); - private getLineMap(); - private setText(newText); +declare namespace ts.server.protocol { + namespace CommandTypes { + type Brace = "brace"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type Implementation = "implementation"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type Navto = "navto"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type References = "references"; + type Reload = "reload"; + type Rename = "rename"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; } - class ScriptInfo { - private readonly host; - readonly fileName: NormalizedPath; - readonly scriptKind: ScriptKind; - hasMixedContent: boolean; - readonly containingProjects: Project[]; - private formatCodeSettings; - readonly path: Path; - private fileWatcher; - private textStorage; - private isOpen; - constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean); - isScriptOpen(): boolean; - open(newText: string): void; - close(): void; - getSnapshot(): IScriptSnapshot; - getFormatCodeSettings(): FormatCodeSettings; - attachToProject(project: Project): boolean; - isAttached(project: Project): boolean; - detachFromProject(project: Project): void; - detachAllProjects(): void; - getDefaultProject(): Project; - registerFileUpdate(): void; - setFormatOptions(formatSettings: FormatCodeSettings): void; - setWatcher(watcher: FileWatcher): void; - stopWatcher(): void; - getLatestVersion(): string; - reload(script: string): void; - saveTo(fileName: string): void; - reloadFromFile(tempFileName?: NormalizedPath): void; - getLineInfo(line: number): ILineInfo; - editContent(start: number, end: number, newText: string): void; - markContainingProjectsAsDirty(): void; - lineToTextSpan(line: number): TextSpan; - lineOffsetToPosition(line: number, offset: number): number; - positionToLineOffset(position: number): ILineInfo; + interface Message { + seq: number; + type: "request" | "response" | "event"; } -} -declare namespace ts.server { - class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost { - private readonly host; - private readonly project; - private readonly cancellationToken; - private compilationSettings; - private readonly resolvedModuleNames; - private readonly resolvedTypeReferenceDirectives; - private readonly getCanonicalFileName; - private filesWithChangedSetOfUnresolvedImports; - private readonly resolveModuleName; - readonly trace: (s: string) => void; - readonly realpath?: (path: string) => string; - constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); - startRecordingFilesWithChangedResolutions(): void; - finishRecordingFilesWithChangedResolutions(): Path[]; - private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, getResultFileName, logChanges); - getNewLine(): string; - getProjectVersion(): string; - getCompilationSettings(): CompilerOptions; - useCaseSensitiveFileNames(): boolean; - getCancellationToken(): HostCancellationToken; - resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModuleFull[]; - getDefaultLibFileName(): string; - getScriptSnapshot(filename: string): ts.IScriptSnapshot; - getScriptFileNames(): string[]; - getTypeRootsVersion(): number; - getScriptKind(fileName: string): ScriptKind; - getScriptVersion(filename: string): string; - getCurrentDirectory(): string; - resolvePath(path: string): string; - fileExists(path: string): boolean; - readFile(fileName: string): string; - directoryExists(path: string): boolean; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; - getDirectories(path: string): string[]; - notifyFileRemoved(info: ScriptInfo): void; - setCompilationSettings(opt: ts.CompilerOptions): void; + interface Request extends Message { + command: string; + arguments?: any; } -} -declare namespace ts.server { - interface ITypingsInstaller { - enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; - attach(projectService: ProjectService): void; - onProjectClosed(p: Project): void; - readonly globalTypingsCacheLocation: string; + interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; } - const nullTypingsInstaller: ITypingsInstaller; - class TypingsCache { - private readonly installer; - private readonly perProjectCache; - constructor(installer: ITypingsInstaller); - getTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray, forceRefresh: boolean): SortedReadonlyArray; - updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]): void; - deleteTypingsForProject(projectName: string): void; - onProjectClosed(project: Project): void; + interface Event extends Message { + event: string; + body?: any; } -} -declare namespace ts.server { - function shouldEmitFile(scriptInfo: ScriptInfo): boolean; - class BuilderFileInfo { - readonly scriptInfo: ScriptInfo; - readonly project: Project; - private lastCheckedShapeSignature; - constructor(scriptInfo: ScriptInfo, project: Project); - isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; - private containsOnlyAmbientModules(sourceFile); - private computeHash(text); - private getSourceFile(); - updateShapeSignature(): boolean; + interface Response extends Message { + request_seq: number; + success: boolean; + command: string; + message?: string; + body?: any; } - interface Builder { - readonly project: Project; - getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; - onProjectUpdateGraph(): void; - emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; - clear(): void; + interface FileRequestArgs { + file: string; + projectFileName?: string; } - function createBuilder(project: Project): Builder; -} -declare namespace ts.server { - enum ProjectKind { - Inferred = 0, - Configured = 1, - External = 2, + interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; } - function allRootFilesAreJsOrDts(project: Project): boolean; - function allFilesAreJsOrDts(project: Project): boolean; - interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { - projectErrors: Diagnostic[]; + interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; } - class UnresolvedImportsMap { - readonly perFileMap: FileMap>; - private version; - clear(): void; - getVersion(): number; - remove(path: Path): void; - get(path: Path): ReadonlyArray; - set(path: Path, value: ReadonlyArray): void; + interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; + arguments: TodoCommentRequestArgs; } - abstract class Project { - private readonly projectName; - readonly projectKind: ProjectKind; - readonly projectService: ProjectService; - private documentRegistry; - private compilerOptions; - compileOnSaveEnabled: boolean; - private rootFiles; - private rootFilesMap; - private lsHost; - private program; - private cachedUnresolvedImportsPerFile; - private lastCachedUnresolvedImportsList; - private readonly languageService; - languageServiceEnabled: boolean; - builder: Builder; - private updatedFileNames; - private lastReportedFileNames; - private lastReportedVersion; - private projectStructureVersion; - private projectStateVersion; - private typingFiles; - protected projectErrors: Diagnostic[]; - typesVersion: number; - isNonTsProject(): boolean; - isJsOnlyProject(): boolean; - getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; - constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); - private setInternalCompilerOptionsForEmittingJsFiles(); - getProjectErrors(): Diagnostic[]; - getLanguageService(ensureSynchronized?: boolean): LanguageService; - getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; - getProjectVersion(): string; - enableLanguageService(): void; - disableLanguageService(): void; - getProjectName(): string; - abstract getProjectRootPath(): string | undefined; - abstract getTypeAcquisition(): TypeAcquisition; - getSourceFile(path: Path): SourceFile; - updateTypes(): void; - close(): void; - getCompilerOptions(): CompilerOptions; - hasRoots(): boolean; - getRootFiles(): NormalizedPath[]; - getRootFilesLSHost(): string[]; - getRootScriptInfos(): ScriptInfo[]; - getScriptInfos(): ScriptInfo[]; - getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; - getFileNames(excludeFilesFromExternalLibraries?: boolean): NormalizedPath[]; - getAllEmittableFiles(): string[]; - containsScriptInfo(info: ScriptInfo): boolean; - containsFile(filename: NormalizedPath, requireOpen?: boolean): boolean; - isRoot(info: ScriptInfo): boolean; - addRoot(info: ScriptInfo): void; - removeFile(info: ScriptInfo, detachFromProject?: boolean): void; - registerFileUpdate(fileName: string): void; - markAsDirty(): void; - private extractUnresolvedImportsFromSourceFile(file, result); - updateGraph(): boolean; - private setTypings(typings); - private updateGraphWorker(); - getScriptInfoLSHost(fileName: string): ScriptInfo; - getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; - getScriptInfo(uncheckedFileName: string): ScriptInfo; - filesToString(): string; - setCompilerOptions(compilerOptions: CompilerOptions): void; - reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; - getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics; - getReferencedFiles(path: Path): Path[]; - private removeRootFileIfNecessary(info); + interface TodoCommentRequestArgs extends FileRequestArgs { + descriptors: TodoCommentDescriptor[]; } - class InferredProject extends Project { - private static newName; - directoriesWatchedForTsconfig: string[]; - constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions); - getProjectRootPath(): string; - close(): void; - getTypeAcquisition(): TypeAcquisition; + interface TodoCommentsResponse extends Response { + body?: TodoComment[]; } - class ConfiguredProject extends Project { - private wildcardDirectories; - compileOnSaveEnabled: boolean; - private typeAcquisition; - private projectFileWatcher; - private directoryWatcher; - private directoriesWatchedForWildcards; - private typeRootsWatchers; - readonly canonicalConfigFilePath: NormalizedPath; - openRefCount: number; - constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); - getConfigFilePath(): string; - getProjectRootPath(): string; - setProjectErrors(projectErrors: Diagnostic[]): void; - setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; - getTypeAcquisition(): TypeAcquisition; - watchConfigFile(callback: (project: ConfiguredProject) => void): void; - watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void): void; - watchConfigDirectory(callback: (project: ConfiguredProject, path: string) => void): void; - watchWildcards(callback: (project: ConfiguredProject, path: string) => void): void; - stopWatchingDirectory(): void; - close(): void; - addOpenRef(): void; - deleteOpenRef(): number; - getEffectiveTypeRoots(): string[]; + interface IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; + arguments: IndentationRequestArgs; } - class ExternalProject extends Project { - compileOnSaveEnabled: boolean; - private readonly projectFilePath; - private typeAcquisition; - constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string); - getProjectRootPath(): string; - getTypeAcquisition(): TypeAcquisition; - setProjectErrors(projectErrors: Diagnostic[]): void; - setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + interface IndentationResponse extends Response { + body?: IndentationResult; } -} -declare namespace ts.server { - const maxProgramSizeForNonTsFiles: number; - const ContextEvent = "context"; - const ConfigFileDiagEvent = "configFileDiag"; - const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; - interface ContextEvent { - eventName: typeof ContextEvent; - data: { - project: Project; - fileName: NormalizedPath; - }; + interface IndentationResult { + position: number; + indentation: number; } - interface ConfigFileDiagEvent { - eventName: typeof ConfigFileDiagEvent; - data: { - triggerFile: string; - configFileName: string; - diagnostics: Diagnostic[]; - }; + interface IndentationRequestArgs extends FileLocationRequestArgs { + options?: EditorSettings; } - interface ProjectLanguageServiceStateEvent { - eventName: typeof ProjectLanguageServiceStateEvent; - data: { - project: Project; - languageServiceEnabled: boolean; - }; + interface ProjectInfoRequestArgs extends FileRequestArgs { + needFileNameList: boolean; } - type ProjectServiceEvent = ContextEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent; - interface ProjectServiceEventHandler { - (event: ProjectServiceEvent): void; + interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; + arguments: ProjectInfoRequestArgs; } - function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; - function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; - function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; - function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind; - function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; - interface HostConfiguration { - formatCodeOptions: FormatCodeSettings; - hostInfo: string; + interface CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; + } + interface CompilerOptionsDiagnosticsRequestArgs { + projectFileName: string; + } + interface ProjectInfo { + configFileName: string; + fileNames?: string[]; + languageServiceDisabled?: boolean; + } + interface DiagnosticWithLinePosition { + message: string; + start: number; + length: number; + startLocation: Location; + endLocation: Location; + category: string; + code: number; + } + interface ProjectInfoResponse extends Response { + body?: ProjectInfo; + } + interface FileRequest extends Request { + arguments: FileRequestArgs; + } + interface FileLocationRequestArgs extends FileRequestArgs { + line: number; + offset: number; + } + interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; + arguments: CodeFixRequestArgs; + } + interface CodeFixRequestArgs extends FileRequestArgs { + startLine: number; + startOffset: number; + endLine: number; + endOffset: number; + errorCodes?: number[]; + } + interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; + } + interface FileLocationRequest extends FileRequest { + arguments: FileLocationRequestArgs; + } + interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; + } + interface GetSupportedCodeFixesResponse extends Response { + body?: string[]; + } + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + start: number; + length: number; + } + interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + filesToSearch: string[]; + } + interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; + } + interface TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; + } + interface ImplementationRequest extends FileLocationRequest { + command: CommandTypes.Implementation; + } + interface Location { + line: number; + offset: number; + } + interface TextSpan { + start: Location; + end: Location; + } + interface FileSpan extends TextSpan { + file: string; + } + interface DefinitionResponse extends Response { + body?: FileSpan[]; + } + interface TypeDefinitionResponse extends Response { + body?: FileSpan[]; + } + interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; + arguments: BraceCompletionRequestArgs; + } + interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + openingBrace: string; + } + interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; + } + interface OccurrencesResponseItem extends FileSpan { + isWriteAccess: boolean; + } + interface OccurrencesResponse extends Response { + body?: OccurrencesResponseItem[]; + } + interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; + arguments: DocumentHighlightsRequestArgs; + } + interface HighlightSpan extends TextSpan { + kind: string; + } + interface DocumentHighlightsItem { + file: string; + highlightSpans: HighlightSpan[]; + } + interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; + } + interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; + } + interface ReferencesResponseItem extends FileSpan { + lineText: string; + isWriteAccess: boolean; + isDefinition: boolean; + } + interface ReferencesResponseBody { + refs: ReferencesResponseItem[]; + symbolName: string; + symbolStartOffset: number; + symbolDisplayString: string; + } + interface ReferencesResponse extends Response { + body?: ReferencesResponseBody; + } + interface RenameRequestArgs extends FileLocationRequestArgs { + findInComments?: boolean; + findInStrings?: boolean; + } + interface RenameRequest extends FileLocationRequest { + command: CommandTypes.Rename; + arguments: RenameRequestArgs; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage?: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + } + interface SpanGroup { + file: string; + locs: TextSpan[]; + } + interface RenameResponseBody { + info: RenameInfo; + locs: SpanGroup[]; + } + interface RenameResponse extends Response { + body?: RenameResponseBody; + } + interface ExternalFile { + fileName: string; + scriptKind?: ScriptKindName | ts.ScriptKind; + hasMixedContent?: boolean; + content?: string; + } + interface ExternalProject { + projectFileName: string; + rootFiles: ExternalFile[]; + options: ExternalProjectCompilerOptions; + typingOptions?: TypeAcquisition; + typeAcquisition?: TypeAcquisition; + } + interface CompileOnSaveMixin { + compileOnSave?: boolean; + } + type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; + interface ProjectChanges { + added: string[]; + removed: string[]; + updated: string[]; + } + interface ConfigureRequestArguments { + hostInfo?: string; + file?: string; + formatOptions?: FormatCodeSettings; extraFileExtensions?: FileExtensionInfo[]; } - interface OpenConfiguredProjectResult { - configFileName?: NormalizedPath; - configFileErrors?: Diagnostic[]; + interface ConfigureRequest extends Request { + command: CommandTypes.Configure; + arguments: ConfigureRequestArguments; } - class ProjectService { - readonly host: ServerHost; - readonly logger: Logger; - readonly cancellationToken: HostCancellationToken; - readonly useSingleInferredProject: boolean; - readonly typingsInstaller: ITypingsInstaller; - private readonly eventHandler; - readonly typingsCache: TypingsCache; - private readonly documentRegistry; - private readonly filenameToScriptInfo; - private readonly externalProjectToConfiguredProjectMap; - readonly externalProjects: ExternalProject[]; - readonly inferredProjects: InferredProject[]; - readonly configuredProjects: ConfiguredProject[]; - readonly openFiles: ScriptInfo[]; - private compilerOptionsForInferredProjects; - private compileOnSaveForInferredProjects; - private readonly directoryWatchers; - private readonly throttledOperations; - private readonly hostConfiguration; - private changedFiles; - readonly toCanonicalFileName: (f: string) => string; - lastDeletedFile: ScriptInfo; - constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); - getChangedFiles_TestOnly(): ScriptInfo[]; - ensureInferredProjectsUpToDate_TestOnly(): void; - getCompilerOptionsForInferredProjects(): CompilerOptions; - onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; - updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; - setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; - stopWatchingDirectory(directory: string): void; - findProject(projectName: string): Project; - getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project; - private ensureInferredProjectsUpToDate(); - private findContainingExternalProject(fileName); - getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings; - private updateProjectGraphs(projects); - private onSourceFileChanged(fileName); - private handleDeletedFile(info); - private onTypeRootFileChanged(project, fileName); - private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); - private handleChangeInSourceFileForConfiguredProject(project, triggerFile); - private onConfigChangedForConfiguredProject(project); - private onConfigFileAddedForInferredProject(fileName); - private getCanonicalFileName(fileName); - private removeProject(project); - private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); - private closeOpenFile(info); - private openOrUpdateConfiguredProjectForFile(fileName); - private findConfigFile(searchPath); - private printProjects(); - private findConfiguredProjectByProjectName(configFileName); - private findExternalProjectByProjectName(projectFileName); - private convertConfigFileContentToProjectOptions(configFilename); - private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); - private createAndAddExternalProject(projectFileName, files, options, typeAcquisition); - private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); - private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); - private watchConfigDirectoryForProject(project, options); - private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors); - private openConfigFile(configFileName, clientFileName?); - private updateNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors); - private updateConfiguredProject(project); - createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject; - getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; - getScriptInfo(uncheckedFileName: string): ScriptInfo; - getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo; - getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; - getScriptInfoForPath(fileName: Path): ScriptInfo; - setHostConfiguration(args: protocol.ConfigureRequestArguments): void; - closeLog(): void; - reloadProjects(): void; - refreshInferredProjects(): void; - openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; - openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; - closeClientFile(uncheckedFileName: string): void; - private collectChanges(lastKnownProjectVersions, currentProjects, result); - synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[]; - applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void; - private closeConfiguredProject(configFile); - closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; - openExternalProjects(projects: protocol.ExternalProject[]): void; - openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; + interface ConfigureResponse extends Response { + } + interface OpenRequestArgs extends FileRequestArgs { + fileContent?: string; + scriptKindName?: ScriptKindName; + } + type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + interface OpenRequest extends Request { + command: CommandTypes.Open; + arguments: OpenRequestArgs; + } + interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; + arguments: OpenExternalProjectArgs; + } + type OpenExternalProjectArgs = ExternalProject; + interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; + arguments: OpenExternalProjectsArgs; + } + interface OpenExternalProjectsArgs { + projects: ExternalProject[]; + } + interface OpenExternalProjectResponse extends Response { + } + interface OpenExternalProjectsResponse extends Response { + } + interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; + arguments: CloseExternalProjectRequestArgs; + } + interface CloseExternalProjectRequestArgs { + projectFileName: string; + } + interface CloseExternalProjectResponse extends Response { + } + interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; + arguments: SetCompilerOptionsForInferredProjectsArgs; + } + interface SetCompilerOptionsForInferredProjectsArgs { + options: ExternalProjectCompilerOptions; + } + interface SetCompilerOptionsForInferredProjectsResponse extends Response { + } + interface ExitRequest extends Request { + command: CommandTypes.Exit; + } + interface CloseRequest extends FileRequest { + command: CommandTypes.Close; + } + interface CompileOnSaveAffectedFileListRequest extends FileRequest { + command: CommandTypes.CompileOnSaveAffectedFileList; + } + interface CompileOnSaveAffectedFileListSingleProject { + projectFileName: string; + fileNames: string[]; + } + interface CompileOnSaveAffectedFileListResponse extends Response { + body: CompileOnSaveAffectedFileListSingleProject[]; + } + interface CompileOnSaveEmitFileRequest extends FileRequest { + command: CommandTypes.CompileOnSaveEmitFile; + arguments: CompileOnSaveEmitFileRequestArgs; + } + interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + forced?: boolean; + } + interface QuickInfoRequest extends FileLocationRequest { + command: CommandTypes.Quickinfo; + } + interface QuickInfoResponseBody { + kind: string; + kindModifiers: string; + start: Location; + end: Location; + displayString: string; + documentation: string; + } + interface QuickInfoResponse extends Response { + body?: QuickInfoResponseBody; + } + interface FormatRequestArgs extends FileLocationRequestArgs { + endLine: number; + endOffset: number; + options?: FormatCodeSettings; + } + interface FormatRequest extends FileLocationRequest { + command: CommandTypes.Format; + arguments: FormatRequestArgs; + } + interface CodeEdit { + start: Location; + end: Location; + newText: string; + } + interface FileCodeEdits { + fileName: string; + textChanges: CodeEdit[]; + } + interface CodeFixResponse extends Response { + body?: CodeAction[]; + } + interface CodeAction { + description: string; + changes: FileCodeEdits[]; + } + interface FormatResponse extends Response { + body?: CodeEdit[]; + } + interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + key: string; + options?: FormatCodeSettings; + } + interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; + arguments: FormatOnKeyRequestArgs; + } + interface CompletionsRequestArgs extends FileLocationRequestArgs { + prefix?: string; + } + interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; + arguments: CompletionsRequestArgs; + } + interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + entryNames: string[]; + } + interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; + arguments: CompletionDetailsRequestArgs; + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + replacementSpan?: TextSpan; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface CompletionsResponse extends Response { + body?: CompletionEntry[]; + } + interface CompletionDetailsResponse extends Response { + body?: CompletionEntryDetails[]; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + } + interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; + arguments: SignatureHelpRequestArgs; + } + interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; + } + interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; + arguments: SemanticDiagnosticsSyncRequestArgs; + } + interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SemanticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; + arguments: SyntacticDiagnosticsSyncRequestArgs; + } + interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SyntacticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface GeterrForProjectRequestArgs { + file: string; + delay: number; + } + interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; + arguments: GeterrForProjectRequestArgs; + } + interface GeterrRequestArgs { + files: string[]; + delay: number; + } + interface GeterrRequest extends Request { + command: CommandTypes.Geterr; + arguments: GeterrRequestArgs; + } + interface Diagnostic { + start: Location; + end: Location; + text: string; + code?: number; + } + interface DiagnosticEventBody { + file: string; + diagnostics: Diagnostic[]; + } + interface DiagnosticEvent extends Event { + body?: DiagnosticEventBody; + } + interface ConfigFileDiagnosticEventBody { + triggerFile: string; + configFile: string; + diagnostics: Diagnostic[]; + } + interface ConfigFileDiagnosticEvent extends Event { + body?: ConfigFileDiagnosticEventBody; + event: "configFileDiag"; + } + type ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; + interface ProjectLanguageServiceStateEvent extends Event { + event: ProjectLanguageServiceStateEventName; + body?: ProjectLanguageServiceStateEventBody; + } + interface ProjectLanguageServiceStateEventBody { + projectName: string; + languageServiceEnabled: boolean; + } + interface ReloadRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; + arguments: ReloadRequestArgs; + } + interface ReloadResponse extends Response { + } + interface SavetoRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; + arguments: SavetoRequestArgs; + } + interface NavtoRequestArgs extends FileRequestArgs { + searchValue: string; + maxResultCount?: number; + currentFileOnly?: boolean; + projectFileName?: string; + } + interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; + arguments: NavtoRequestArgs; + } + interface NavtoItem { + name: string; + kind: string; + matchKind?: string; + isCaseSensitive?: boolean; + kindModifiers?: string; + file: string; + start: Location; + end: Location; + containerName?: string; + containerKind?: string; + } + interface NavtoResponse extends Response { + body?: NavtoItem[]; + } + interface ChangeRequestArgs extends FormatRequestArgs { + insertString?: string; + } + interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; + arguments: ChangeRequestArgs; + } + interface BraceResponse extends Response { + body?: TextSpan[]; + } + interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; + } + interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; + } + interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers?: string; + spans: TextSpan[]; + childItems?: NavigationBarItem[]; + indent: number; + } + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } + type TelemetryEventName = "telemetry"; + interface TelemetryEvent extends Event { + event: TelemetryEventName; + body: TelemetryEventBody; + } + interface TelemetryEventBody { + telemetryEventName: string; + payload: any; + } + type TypingsInstalledTelemetryEventName = "typingsInstalled"; + interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { + telemetryEventName: TypingsInstalledTelemetryEventName; + payload: TypingsInstalledTelemetryEventPayload; + } + interface TypingsInstalledTelemetryEventPayload { + installedPackages: string; + installSuccess: boolean; + typingsInstallerVersion: string; + } + type BeginInstallTypesEventName = "beginInstallTypes"; + type EndInstallTypesEventName = "endInstallTypes"; + interface BeginInstallTypesEvent extends Event { + event: BeginInstallTypesEventName; + body: BeginInstallTypesEventBody; + } + interface EndInstallTypesEvent extends Event { + event: EndInstallTypesEventName; + body: EndInstallTypesEventBody; + } + interface InstallTypesEventBody { + eventId: number; + packages: ReadonlyArray; + } + interface BeginInstallTypesEventBody extends InstallTypesEventBody { + } + interface EndInstallTypesEventBody extends InstallTypesEventBody { + success: boolean; + } + interface NavBarResponse extends Response { + body?: NavigationBarItem[]; + } + interface NavTreeResponse extends Response { + body?: NavigationTree; + } + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; + } + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle | ts.IndentStyle; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; + } + interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit | ts.JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind | ts.ModuleKind; + moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine?: NewLineKind | ts.NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; + noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + outFile?: string; + paths?: MapLike; + preserveConstEnums?: boolean; + project?: string; + reactNamespace?: string; + removeComments?: boolean; + rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + strictNullChecks?: boolean; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget | ts.ScriptTarget; + traceResolution?: boolean; + types?: string[]; + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; + } + namespace JsxEmit { + type None = "None"; + type Preserve = "Preserve"; + type React = "React"; + } + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + namespace ModuleKind { + type None = "None"; + type CommonJS = "CommonJS"; + type AMD = "AMD"; + type UMD = "UMD"; + type System = "System"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + namespace ModuleResolutionKind { + type Classic = "Classic"; + type Node = "Node"; + } + type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + namespace NewLineKind { + type Crlf = "Crlf"; + type Lf = "Lf"; + } + type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + namespace ScriptTarget { + type ES3 = "ES3"; + type ES5 = "ES5"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; +} +declare namespace ts.server { + interface CompressedData { + length: number; + compressionKind: string; + data: any; + } + interface ServerHost extends System { + setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; + clearTimeout(timeoutId: any): void; + setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; + clearImmediate(timeoutId: any): void; + gc?(): void; + trace?(s: string): void; + } + interface SortedReadonlyArray extends ReadonlyArray { + " __sortedReadonlyArrayBrand": any; + } + interface TypingInstallerRequest { + readonly projectName: string; + readonly kind: "discover" | "closeProject"; + } + interface DiscoverTypings extends TypingInstallerRequest { + readonly fileNames: string[]; + readonly projectRootPath: ts.Path; + readonly compilerOptions: ts.CompilerOptions; + readonly typeAcquisition: ts.TypeAcquisition; + readonly unresolvedImports: SortedReadonlyArray; + readonly cachePath?: string; + readonly kind: "discover"; + } + interface CloseProject extends TypingInstallerRequest { + readonly kind: "closeProject"; + } + type ActionSet = "action::set"; + type ActionInvalidate = "action::invalidate"; + type EventBeginInstallTypes = "event::beginInstallTypes"; + type EventEndInstallTypes = "event::endInstallTypes"; + interface TypingInstallerResponse { + readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes; + } + interface ProjectResponse extends TypingInstallerResponse { + readonly projectName: string; + } + interface SetTypings extends ProjectResponse { + readonly typeAcquisition: ts.TypeAcquisition; + readonly compilerOptions: ts.CompilerOptions; + readonly typings: string[]; + readonly unresolvedImports: SortedReadonlyArray; + readonly kind: ActionSet; + } + interface InvalidateCachedTypings extends ProjectResponse { + readonly kind: ActionInvalidate; + } + interface InstallTypes extends ProjectResponse { + readonly kind: EventBeginInstallTypes | EventEndInstallTypes; + readonly eventId: number; + readonly typingsInstallerVersion: string; + readonly packagesToInstall: ReadonlyArray; + } + interface BeginInstallTypes extends InstallTypes { + readonly kind: EventBeginInstallTypes; + } + interface EndInstallTypes extends InstallTypes { + readonly kind: EventEndInstallTypes; + readonly installSuccess: boolean; } } declare namespace ts.server { - interface PendingErrorCheck { - fileName: NormalizedPath; - project: Project; + const ActionSet: ActionSet; + const ActionInvalidate: ActionInvalidate; + const EventBeginInstallTypes: EventBeginInstallTypes; + const EventEndInstallTypes: EventEndInstallTypes; + namespace Arguments { + const GlobalCacheLocation = "--globalTypingsCacheLocation"; + const LogFile = "--logFile"; + const EnableTelemetry = "--enableTelemetry"; } - interface EventSender { - event(payload: any, eventName: string): void; + function hasArgument(argumentName: string): boolean; + function findArgument(argumentName: string): string; +} +declare namespace ts.server { + enum LogLevel { + terse = 0, + normal = 1, + requestTime = 2, + verbose = 3, } - namespace CommandNames { - const Brace: protocol.CommandTypes.Brace; - const BraceFull: protocol.CommandTypes.BraceFull; - const BraceCompletion: protocol.CommandTypes.BraceCompletion; - const Change: protocol.CommandTypes.Change; - const Close: protocol.CommandTypes.Close; - const Completions: protocol.CommandTypes.Completions; - const CompletionsFull: protocol.CommandTypes.CompletionsFull; - const CompletionDetails: protocol.CommandTypes.CompletionDetails; - const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; - const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; - const Configure: protocol.CommandTypes.Configure; - const Definition: protocol.CommandTypes.Definition; - const DefinitionFull: protocol.CommandTypes.DefinitionFull; - const Exit: protocol.CommandTypes.Exit; - const Format: protocol.CommandTypes.Format; - const Formatonkey: protocol.CommandTypes.Formatonkey; - const FormatFull: protocol.CommandTypes.FormatFull; - const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull; - const FormatRangeFull: protocol.CommandTypes.FormatRangeFull; - const Geterr: protocol.CommandTypes.Geterr; - const GeterrForProject: protocol.CommandTypes.GeterrForProject; - const Implementation: protocol.CommandTypes.Implementation; - const ImplementationFull: protocol.CommandTypes.ImplementationFull; - const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; - const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; - const NavBar: protocol.CommandTypes.NavBar; - const NavBarFull: protocol.CommandTypes.NavBarFull; - const NavTree: protocol.CommandTypes.NavTree; - const NavTreeFull: protocol.CommandTypes.NavTreeFull; - const Navto: protocol.CommandTypes.Navto; - const NavtoFull: protocol.CommandTypes.NavtoFull; - const Occurrences: protocol.CommandTypes.Occurrences; - const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; - const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull; - const Open: protocol.CommandTypes.Open; - const Quickinfo: protocol.CommandTypes.Quickinfo; - const QuickinfoFull: protocol.CommandTypes.QuickinfoFull; - const References: protocol.CommandTypes.References; - const ReferencesFull: protocol.CommandTypes.ReferencesFull; - const Reload: protocol.CommandTypes.Reload; - const Rename: protocol.CommandTypes.Rename; - const RenameInfoFull: protocol.CommandTypes.RenameInfoFull; - const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull; - const Saveto: protocol.CommandTypes.Saveto; - const SignatureHelp: protocol.CommandTypes.SignatureHelp; - const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull; - const TypeDefinition: protocol.CommandTypes.TypeDefinition; - const ProjectInfo: protocol.CommandTypes.ProjectInfo; - const ReloadProjects: protocol.CommandTypes.ReloadProjects; - const Unknown: protocol.CommandTypes.Unknown; - const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; - const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; - const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; - const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList; - const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles; - const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull; - const Cleanup: protocol.CommandTypes.Cleanup; - const OutliningSpans: protocol.CommandTypes.OutliningSpans; - const TodoComments: protocol.CommandTypes.TodoComments; - const Indentation: protocol.CommandTypes.Indentation; - const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; - const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull; - const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan; - const BreakpointStatement: protocol.CommandTypes.BreakpointStatement; - const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; - const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; - const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull; - const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; + const emptyArray: ReadonlyArray; + interface Logger { + close(): void; + hasLevel(level: LogLevel): boolean; + loggingEnabled(): boolean; + perftrc(s: string): void; + info(s: string): void; + startGroup(): void; + endGroup(): void; + msg(s: string, type?: Msg.Types): void; + getLogFileName(): string; } - function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; - class Session implements EventSender { - private host; - protected readonly typingsInstaller: ITypingsInstaller; - private byteLength; - private hrtime; - protected logger: Logger; - protected readonly canUseEvents: boolean; - private readonly gcTimer; - protected projectService: ProjectService; - private errorTimer; - private immediateId; - private changeSeq; - private eventHander; - constructor(host: ServerHost, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); - private defaultEventHandler(event); - logError(err: Error, cmd: string): void; - send(msg: protocol.Message): void; - configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]): void; - event(info: any, eventName: string): void; - output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; - private semanticCheck(file, project); - private syntacticCheck(file, project); - private updateProjectStructure(seq, matchSeq, ms?); - private updateErrorCheck(checkList, seq, matchSeq, ms?, followMs?, requireOpen?); - private cleanProjects(caption, projects); - private cleanup(); - private getEncodedSemanticClassifications(args); - private getProject(projectFileName); - private getCompilerOptionsDiagnostics(args); - private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); - private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); - private getDefinition(args, simplifiedResult); - private getTypeDefinition(args); - private getImplementation(args, simplifiedResult); - private getOccurrences(args); - private getSyntacticDiagnosticsSync(args); - private getSemanticDiagnosticsSync(args); - private getDocumentHighlights(args, simplifiedResult); - private setCompilerOptionsForInferredProjects(args); - private getProjectInfo(args); - private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList); - private getRenameInfo(args); - private getProjects(args); - private getRenameLocations(args, simplifiedResult); - private getReferences(args, simplifiedResult); - private openClientFile(fileName, fileContent?, scriptKind?); - private getPosition(args, scriptInfo); - private getFileAndProject(args, errorOnMissingProject?); - private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); - private getFileAndProjectWorker(uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject); - private getOutliningSpans(args); - private getTodoComments(args); - private getDocCommentTemplate(args); - private getIndentation(args); - private getBreakpointStatement(args); - private getNameOrDottedNameSpan(args); - private isValidBraceCompletion(args); - private getQuickInfoWorker(args, simplifiedResult); - private getFormattingEditsForRange(args); - private getFormattingEditsForRangeFull(args); - private getFormattingEditsForDocumentFull(args); - private getFormattingEditsAfterKeystrokeFull(args); - private getFormattingEditsAfterKeystroke(args); - private getCompletions(args, simplifiedResult); - private getCompletionEntryDetails(args); - private getCompileOnSaveAffectedFileList(args); - private emitFile(args); - private getSignatureHelpItems(args, simplifiedResult); - private getDiagnostics(delay, fileNames); - private change(args); - private reload(args, reqSeq); - private saveToTmp(fileName, tempFileName); - private closeClientFile(fileName); - private decorateNavigationBarItems(items, scriptInfo); - private getNavigationBarItems(args, simplifiedResult); - private decorateNavigationTree(tree, scriptInfo); - private decorateSpan(span, scriptInfo); - private getNavigationTree(args, simplifiedResult); - private getNavigateToItems(args, simplifiedResult); - private getSupportedCodeFixes(); - private getCodeFixes(args, simplifiedResult); - private mapCodeAction(codeAction, scriptInfo); - private convertTextChangeToCodeEdit(change, scriptInfo); - private getBraceMatching(args, simplifiedResult); - getDiagnosticsForProject(delay: number, fileName: string): void; - getCanonicalFileName(fileName: string): string; - exit(): void; - private notRequired(); - private requiredResponse(response); - private handlers; - addProtocolHandler(command: string, handler: (request: protocol.Request) => { - response?: any; - responseRequired: boolean; - }): void; - executeCommand(request: protocol.Request): { - response?: any; - responseRequired?: boolean; - }; - onMessage(message: string): void; + namespace Msg { + type Err = "Err"; + const Err: Err; + type Info = "Info"; + const Info: Info; + type Perf = "Perf"; + const Perf: Perf; + type Types = Err | Info | Perf; + } + function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; + namespace Errors { + function ThrowNoProject(): never; + function ThrowProjectLanguageServiceDisabled(): never; + function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; + } + function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; + function mergeMaps(target: MapLike, source: MapLike): void; + function removeItemFromSet(items: T[], itemToRemove: T): void; + type NormalizedPath = string & { + __normalizedPathTag: any; + }; + function toNormalizedPath(fileName: string): NormalizedPath; + function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; + function asNormalizedPath(fileName: string): NormalizedPath; + interface NormalizedPathMap { + get(path: NormalizedPath): T; + set(path: NormalizedPath, value: T): void; + contains(path: NormalizedPath): boolean; + remove(path: NormalizedPath): void; + } + function createNormalizedPathMap(): NormalizedPathMap; + interface ProjectOptions { + configHasFilesProperty?: boolean; + files?: string[]; + wildcardDirectories?: Map; + compilerOptions?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + compileOnSave?: boolean; + } + function isInferredProjectName(name: string): boolean; + function makeInferredProjectName(counter: number): string; + function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; + class ThrottledOperations { + private readonly host; + private pendingTimeouts; + constructor(host: ServerHost); + schedule(operationId: string, delay: number, cb: () => void): void; + private static run(self, operationId, cb); + } + class GcTimer { + private readonly host; + private readonly delay; + private readonly logger; + private timerId; + constructor(host: ServerHost, delay: number, logger: Logger); + scheduleCollect(): void; + private static run(self); } } declare namespace ts.server { @@ -11841,178 +3927,541 @@ declare namespace ts.server { lineCount(): number; } } -declare let debugObjectHost: any; -declare namespace ts { - interface ScriptSnapshotShim { - getText(start: number, end: number): string; - getLength(): number; - getChangeRange(oldSnapshot: ScriptSnapshotShim): string; - dispose?(): void; - } - interface Logger { - log(s: string): void; - trace(s: string): void; - error(s: string): void; - } - interface LanguageServiceShimHost extends Logger { - getCompilationSettings(): string; - getScriptFileNames(): string; - getScriptKind?(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getScriptSnapshot(fileName: string): ScriptSnapshotShim; - getLocalizedDiagnosticMessages(): string; - getCancellationToken(): HostCancellationToken; - getCurrentDirectory(): string; - getDirectories(path: string): string; - getDefaultLibFileName(options: string): string; - getNewLine?(): string; - getProjectVersion?(): string; - useCaseSensitiveFileNames?(): boolean; - getTypeRootsVersion?(): number; - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; - getModuleResolutionsForFile?(fileName: string): string; - getTypeReferenceDirectiveResolutionsForFile?(fileName: string): string; - directoryExists(directoryName: string): boolean; - } - interface CoreServicesShimHost extends Logger { - directoryExists(directoryName: string): boolean; - fileExists(fileName: string): boolean; - getCurrentDirectory(): string; - getDirectories(path: string): string; - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - readFile(fileName: string): string; - realpath?(path: string): string; - trace(s: string): void; - useCaseSensitiveFileNames?(): boolean; - } - interface IFileReference { - path: string; - position: number; - length: number; - } - interface ShimFactory { - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; - } - interface Shim { - dispose(_dummy: any): void; - } - interface LanguageServiceShim extends Shim { - languageService: LanguageService; - dispose(_dummy: any): void; - refresh(throwOnError: boolean): void; - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): string; - getSemanticDiagnostics(fileName: string): string; - getCompilerOptionsDiagnostics(): string; - getSyntacticClassifications(fileName: string, start: number, length: number): string; - getSemanticClassifications(fileName: string, start: number, length: number): string; - getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string; - getEncodedSemanticClassifications(fileName: string, start: number, length: number): string; - getCompletionsAtPosition(fileName: string, position: number): string; - getCompletionEntryDetails(fileName: string, position: number, entryName: string): string; - getQuickInfoAtPosition(fileName: string, position: number): string; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string; - getBreakpointStatementAtPosition(fileName: string, position: number): string; - getSignatureHelpItems(fileName: string, position: number): string; - getRenameInfo(fileName: string, position: number): string; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string; - getDefinitionAtPosition(fileName: string, position: number): string; - getTypeDefinitionAtPosition(fileName: string, position: number): string; - getImplementationAtPosition(fileName: string, position: number): string; - getReferencesAtPosition(fileName: string, position: number): string; - findReferences(fileName: string, position: number): string; - getOccurrencesAtPosition(fileName: string, position: number): string; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): string; - getNavigationBarItems(fileName: string): string; - getNavigationTree(fileName: string): string; - getOutliningSpans(fileName: string): string; - getTodoComments(fileName: string, todoCommentDescriptors: string): string; - getBraceMatchingAtPosition(fileName: string, position: number): string; - getIndentationAtPosition(fileName: string, position: number, options: string): string; - getFormattingEditsForRange(fileName: string, start: number, end: number, options: string): string; - getFormattingEditsForDocument(fileName: string, options: string): string; - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string): string; - getDocCommentTemplateAtPosition(fileName: string, position: number): string; - isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; - getEmitOutput(fileName: string): string; - getEmitOutputObject(fileName: string): EmitOutput; - } - interface ClassifierShim extends Shim { - getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; - getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; - } - interface CoreServicesShim extends Shim { - getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string; - getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string; - getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; - getDefaultCompilationSettings(): string; - discoverTypings(discoverTypingsJson: string): string; - } - class LanguageServiceShimHostAdapter implements LanguageServiceHost { - private shimHost; - private files; - private loggingEnabled; - private tracingEnabled; - resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModuleFull[]; - resolveTypeReferenceDirectives: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[]; - directoryExists: (directoryName: string) => boolean; - constructor(shimHost: LanguageServiceShimHost); - log(s: string): void; - trace(s: string): void; - error(s: string): void; - getProjectVersion(): string; - getTypeRootsVersion(): number; - useCaseSensitiveFileNames(): boolean; - getCompilationSettings(): CompilerOptions; - getScriptFileNames(): string[]; - getScriptSnapshot(fileName: string): IScriptSnapshot; - getScriptKind(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getLocalizedDiagnosticMessages(): any; - getCancellationToken(): HostCancellationToken; - getCurrentDirectory(): string; - getDirectories(path: string): string[]; - getDefaultLibFileName(options: CompilerOptions): string; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[]; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; - } - class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { - private shimHost; - directoryExists: (directoryName: string) => boolean; - realpath: (path: string) => string; - useCaseSensitiveFileNames: boolean; - constructor(shimHost: CoreServicesShimHost); - readDirectory(rootDir: string, extensions: string[], exclude: string[], include: string[], depth?: number): string[]; - fileExists(fileName: string): boolean; - readFile(fileName: string): string; - private readDirectoryFallback(rootDir, extension, exclude); - getDirectories(path: string): string[]; - } - function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { - message: string; - start: number; - length: number; - category: string; - code: number; - }[]; - class TypeScriptServicesFactory implements ShimFactory { - private _shims; - private documentRegistry; - getServicesVersion(): string; - createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim; - createClassifierShim(logger: Logger): ClassifierShim; - createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim; +declare namespace ts.server { + class ScriptInfo { + private readonly host; + readonly fileName: NormalizedPath; + readonly scriptKind: ScriptKind; + hasMixedContent: boolean; + readonly containingProjects: Project[]; + private formatCodeSettings; + readonly path: Path; + private fileWatcher; + private textStorage; + private isOpen; + constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean); + isScriptOpen(): boolean; + open(newText: string): void; close(): void; - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; + getSnapshot(): IScriptSnapshot; + getFormatCodeSettings(): FormatCodeSettings; + attachToProject(project: Project): boolean; + isAttached(project: Project): boolean; + detachFromProject(project: Project): void; + detachAllProjects(): void; + getDefaultProject(): Project; + registerFileUpdate(): void; + setFormatOptions(formatSettings: FormatCodeSettings): void; + setWatcher(watcher: FileWatcher): void; + stopWatcher(): void; + getLatestVersion(): string; + reload(script: string): void; + saveTo(fileName: string): void; + reloadFromFile(tempFileName?: NormalizedPath): void; + getLineInfo(line: number): ILineInfo; + editContent(start: number, end: number, newText: string): void; + markContainingProjectsAsDirty(): void; + lineToTextSpan(line: number): TextSpan; + lineOffsetToPosition(line: number, offset: number): number; + positionToLineOffset(position: number): ILineInfo; } } -declare namespace TypeScript.Services { - const TypeScriptServicesFactory: typeof ts.TypeScriptServicesFactory; +declare namespace ts.server { + class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost { + private readonly host; + private readonly project; + private readonly cancellationToken; + private compilationSettings; + private readonly resolvedModuleNames; + private readonly resolvedTypeReferenceDirectives; + private readonly getCanonicalFileName; + private filesWithChangedSetOfUnresolvedImports; + private readonly resolveModuleName; + readonly trace: (s: string) => void; + readonly realpath?: (path: string) => string; + constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); + startRecordingFilesWithChangedResolutions(): void; + finishRecordingFilesWithChangedResolutions(): Path[]; + private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, getResultFileName, logChanges); + getNewLine(): string; + getProjectVersion(): string; + getCompilationSettings(): CompilerOptions; + useCaseSensitiveFileNames(): boolean; + getCancellationToken(): HostCancellationToken; + resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModuleFull[]; + getDefaultLibFileName(): string; + getScriptSnapshot(filename: string): ts.IScriptSnapshot; + getScriptFileNames(): string[]; + getTypeRootsVersion(): number; + getScriptKind(fileName: string): ScriptKind; + getScriptVersion(filename: string): string; + getCurrentDirectory(): string; + resolvePath(path: string): string; + fileExists(path: string): boolean; + readFile(fileName: string): string; + directoryExists(path: string): boolean; + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; + getDirectories(path: string): string[]; + notifyFileRemoved(info: ScriptInfo): void; + setCompilationSettings(opt: ts.CompilerOptions): void; + } } -declare const toolsVersion = "2.2"; +declare namespace ts.server { + interface ITypingsInstaller { + enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; + attach(projectService: ProjectService): void; + onProjectClosed(p: Project): void; + readonly globalTypingsCacheLocation: string; + } + const nullTypingsInstaller: ITypingsInstaller; + class TypingsCache { + private readonly installer; + private readonly perProjectCache; + constructor(installer: ITypingsInstaller); + getTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray, forceRefresh: boolean): SortedReadonlyArray; + updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]): void; + deleteTypingsForProject(projectName: string): void; + onProjectClosed(project: Project): void; + } +} +declare namespace ts.server { + enum ProjectKind { + Inferred = 0, + Configured = 1, + External = 2, + } + function allRootFilesAreJsOrDts(project: Project): boolean; + function allFilesAreJsOrDts(project: Project): boolean; + class UnresolvedImportsMap { + readonly perFileMap: FileMap>; + private version; + clear(): void; + getVersion(): number; + remove(path: Path): void; + get(path: Path): ReadonlyArray; + set(path: Path, value: ReadonlyArray): void; + } + abstract class Project { + private readonly projectName; + readonly projectKind: ProjectKind; + readonly projectService: ProjectService; + private documentRegistry; + private compilerOptions; + compileOnSaveEnabled: boolean; + private rootFiles; + private rootFilesMap; + private lsHost; + private program; + private cachedUnresolvedImportsPerFile; + private lastCachedUnresolvedImportsList; + private readonly languageService; + languageServiceEnabled: boolean; + builder: Builder; + private updatedFileNames; + private lastReportedFileNames; + private lastReportedVersion; + private projectStructureVersion; + private projectStateVersion; + private typingFiles; + protected projectErrors: Diagnostic[]; + typesVersion: number; + isNonTsProject(): boolean; + isJsOnlyProject(): boolean; + getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; + constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); + private setInternalCompilerOptionsForEmittingJsFiles(); + getProjectErrors(): Diagnostic[]; + getLanguageService(ensureSynchronized?: boolean): LanguageService; + getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; + getProjectVersion(): string; + enableLanguageService(): void; + disableLanguageService(): void; + getProjectName(): string; + abstract getProjectRootPath(): string | undefined; + abstract getTypeAcquisition(): TypeAcquisition; + getSourceFile(path: Path): SourceFile; + updateTypes(): void; + close(): void; + getCompilerOptions(): CompilerOptions; + hasRoots(): boolean; + getRootFiles(): NormalizedPath[]; + getRootFilesLSHost(): string[]; + getRootScriptInfos(): ScriptInfo[]; + getScriptInfos(): ScriptInfo[]; + getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; + getFileNames(excludeFilesFromExternalLibraries?: boolean): NormalizedPath[]; + getAllEmittableFiles(): string[]; + containsScriptInfo(info: ScriptInfo): boolean; + containsFile(filename: NormalizedPath, requireOpen?: boolean): boolean; + isRoot(info: ScriptInfo): boolean; + addRoot(info: ScriptInfo): void; + removeFile(info: ScriptInfo, detachFromProject?: boolean): void; + registerFileUpdate(fileName: string): void; + markAsDirty(): void; + private extractUnresolvedImportsFromSourceFile(file, result); + updateGraph(): boolean; + private setTypings(typings); + private updateGraphWorker(); + getScriptInfoLSHost(fileName: string): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo; + filesToString(): string; + setCompilerOptions(compilerOptions: CompilerOptions): void; + reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; + getReferencedFiles(path: Path): Path[]; + private removeRootFileIfNecessary(info); + } + class InferredProject extends Project { + private static newName; + directoriesWatchedForTsconfig: string[]; + constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions); + getProjectRootPath(): string; + close(): void; + getTypeAcquisition(): TypeAcquisition; + } + class ConfiguredProject extends Project { + private wildcardDirectories; + compileOnSaveEnabled: boolean; + private typeAcquisition; + private projectFileWatcher; + private directoryWatcher; + private directoriesWatchedForWildcards; + private typeRootsWatchers; + readonly canonicalConfigFilePath: NormalizedPath; + openRefCount: number; + constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); + getConfigFilePath(): string; + getProjectRootPath(): string; + setProjectErrors(projectErrors: Diagnostic[]): void; + setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + getTypeAcquisition(): TypeAcquisition; + watchConfigFile(callback: (project: ConfiguredProject) => void): void; + watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void): void; + watchConfigDirectory(callback: (project: ConfiguredProject, path: string) => void): void; + watchWildcards(callback: (project: ConfiguredProject, path: string) => void): void; + stopWatchingDirectory(): void; + close(): void; + addOpenRef(): void; + deleteOpenRef(): number; + getEffectiveTypeRoots(): string[]; + } + class ExternalProject extends Project { + compileOnSaveEnabled: boolean; + private readonly projectFilePath; + private typeAcquisition; + constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string); + getProjectRootPath(): string; + getTypeAcquisition(): TypeAcquisition; + setProjectErrors(projectErrors: Diagnostic[]): void; + setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + } +} +declare namespace ts.server { + const maxProgramSizeForNonTsFiles: number; + const ContextEvent = "context"; + const ConfigFileDiagEvent = "configFileDiag"; + const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; + interface ContextEvent { + eventName: typeof ContextEvent; + data: { + project: Project; + fileName: NormalizedPath; + }; + } + interface ConfigFileDiagEvent { + eventName: typeof ConfigFileDiagEvent; + data: { + triggerFile: string; + configFileName: string; + diagnostics: Diagnostic[]; + }; + } + interface ProjectLanguageServiceStateEvent { + eventName: typeof ProjectLanguageServiceStateEvent; + data: { + project: Project; + languageServiceEnabled: boolean; + }; + } + type ProjectServiceEvent = ContextEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent; + interface ProjectServiceEventHandler { + (event: ProjectServiceEvent): void; + } + function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; + function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; + function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; + function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind; + function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; + interface HostConfiguration { + formatCodeOptions: FormatCodeSettings; + hostInfo: string; + extraFileExtensions?: FileExtensionInfo[]; + } + interface OpenConfiguredProjectResult { + configFileName?: NormalizedPath; + configFileErrors?: Diagnostic[]; + } + class ProjectService { + readonly host: ServerHost; + readonly logger: Logger; + readonly cancellationToken: HostCancellationToken; + readonly useSingleInferredProject: boolean; + readonly typingsInstaller: ITypingsInstaller; + private readonly eventHandler; + readonly typingsCache: TypingsCache; + private readonly documentRegistry; + private readonly filenameToScriptInfo; + private readonly externalProjectToConfiguredProjectMap; + readonly externalProjects: ExternalProject[]; + readonly inferredProjects: InferredProject[]; + readonly configuredProjects: ConfiguredProject[]; + readonly openFiles: ScriptInfo[]; + private compilerOptionsForInferredProjects; + private compileOnSaveForInferredProjects; + private readonly directoryWatchers; + private readonly throttledOperations; + private readonly hostConfiguration; + private changedFiles; + readonly toCanonicalFileName: (f: string) => string; + lastDeletedFile: ScriptInfo; + constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); + ensureInferredProjectsUpToDate_TestOnly(): void; + getCompilerOptionsForInferredProjects(): CompilerOptions; + onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; + updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; + setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; + stopWatchingDirectory(directory: string): void; + findProject(projectName: string): Project; + getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project; + private ensureInferredProjectsUpToDate(); + private findContainingExternalProject(fileName); + getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings; + private updateProjectGraphs(projects); + private onSourceFileChanged(fileName); + private handleDeletedFile(info); + private onTypeRootFileChanged(project, fileName); + private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); + private handleChangeInSourceFileForConfiguredProject(project, triggerFile); + private onConfigChangedForConfiguredProject(project); + private onConfigFileAddedForInferredProject(fileName); + private getCanonicalFileName(fileName); + private removeProject(project); + private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); + private closeOpenFile(info); + private openOrUpdateConfiguredProjectForFile(fileName); + private findConfigFile(searchPath); + private printProjects(); + private findConfiguredProjectByProjectName(configFileName); + private findExternalProjectByProjectName(projectFileName); + private convertConfigFileContentToProjectOptions(configFilename); + private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); + private createAndAddExternalProject(projectFileName, files, options, typeAcquisition); + private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); + private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); + private watchConfigDirectoryForProject(project, options); + private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors); + private openConfigFile(configFileName, clientFileName?); + private updateNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors); + private updateConfiguredProject(project); + createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject; + getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo; + getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfoForPath(fileName: Path): ScriptInfo; + setHostConfiguration(args: protocol.ConfigureRequestArguments): void; + closeLog(): void; + reloadProjects(): void; + refreshInferredProjects(): void; + openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; + openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; + closeClientFile(uncheckedFileName: string): void; + private collectChanges(lastKnownProjectVersions, currentProjects, result); + private closeConfiguredProject(configFile); + closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; + openExternalProjects(projects: protocol.ExternalProject[]): void; + openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; + } +} +declare namespace ts.server { + interface PendingErrorCheck { + fileName: NormalizedPath; + project: Project; + } + interface EventSender { + event(payload: any, eventName: string): void; + } + namespace CommandNames { + const Brace: protocol.CommandTypes.Brace; + const BraceCompletion: protocol.CommandTypes.BraceCompletion; + const Change: protocol.CommandTypes.Change; + const Close: protocol.CommandTypes.Close; + const Completions: protocol.CommandTypes.Completions; + const CompletionDetails: protocol.CommandTypes.CompletionDetails; + const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; + const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; + const Configure: protocol.CommandTypes.Configure; + const Definition: protocol.CommandTypes.Definition; + const Exit: protocol.CommandTypes.Exit; + const Format: protocol.CommandTypes.Format; + const Formatonkey: protocol.CommandTypes.Formatonkey; + const Geterr: protocol.CommandTypes.Geterr; + const GeterrForProject: protocol.CommandTypes.GeterrForProject; + const Implementation: protocol.CommandTypes.Implementation; + const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; + const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; + const NavBar: protocol.CommandTypes.NavBar; + const NavTree: protocol.CommandTypes.NavTree; + const NavTreeFull: protocol.CommandTypes.NavTreeFull; + const Navto: protocol.CommandTypes.Navto; + const Occurrences: protocol.CommandTypes.Occurrences; + const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; + const Open: protocol.CommandTypes.Open; + const Quickinfo: protocol.CommandTypes.Quickinfo; + const References: protocol.CommandTypes.References; + const Reload: protocol.CommandTypes.Reload; + const Rename: protocol.CommandTypes.Rename; + const Saveto: protocol.CommandTypes.Saveto; + const SignatureHelp: protocol.CommandTypes.SignatureHelp; + const TypeDefinition: protocol.CommandTypes.TypeDefinition; + const ProjectInfo: protocol.CommandTypes.ProjectInfo; + const ReloadProjects: protocol.CommandTypes.ReloadProjects; + const Unknown: protocol.CommandTypes.Unknown; + const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; + const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; + const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; + const TodoComments: protocol.CommandTypes.TodoComments; + const Indentation: protocol.CommandTypes.Indentation; + const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; + const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; + const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; + const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; + } + function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; + class Session implements EventSender { + private host; + protected readonly typingsInstaller: ITypingsInstaller; + private byteLength; + private hrtime; + protected logger: Logger; + protected readonly canUseEvents: boolean; + private readonly gcTimer; + protected projectService: ProjectService; + private errorTimer; + private immediateId; + private changeSeq; + private eventHander; + constructor(host: ServerHost, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); + private defaultEventHandler(event); + logError(err: Error, cmd: string): void; + send(msg: protocol.Message): void; + configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]): void; + event(info: any, eventName: string): void; + output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; + private semanticCheck(file, project); + private syntacticCheck(file, project); + private updateProjectStructure(seq, matchSeq, ms?); + private updateErrorCheck(checkList, seq, matchSeq, ms?, followMs?, requireOpen?); + private cleanProjects(caption, projects); + private cleanup(); + private getEncodedSemanticClassifications(args); + private getProject(projectFileName); + private getCompilerOptionsDiagnostics(args); + private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); + private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); + private getDefinition(args, simplifiedResult); + private getTypeDefinition(args); + private getImplementation(args, simplifiedResult); + private getOccurrences(args); + private getSyntacticDiagnosticsSync(args); + private getSemanticDiagnosticsSync(args); + private getDocumentHighlights(args, simplifiedResult); + private setCompilerOptionsForInferredProjects(args); + private getProjectInfo(args); + private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList); + private getRenameInfo(args); + private getProjects(args); + private getRenameLocations(args, simplifiedResult); + private getReferences(args, simplifiedResult); + private openClientFile(fileName, fileContent?, scriptKind?); + private getPosition(args, scriptInfo); + private getFileAndProject(args, errorOnMissingProject?); + private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); + private getFileAndProjectWorker(uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject); + private getOutliningSpans(args); + private getTodoComments(args); + private getDocCommentTemplate(args); + private getIndentation(args); + private getBreakpointStatement(args); + private getNameOrDottedNameSpan(args); + private isValidBraceCompletion(args); + private getQuickInfoWorker(args, simplifiedResult); + private getFormattingEditsForRange(args); + private getFormattingEditsForRangeFull(args); + private getFormattingEditsForDocumentFull(args); + private getFormattingEditsAfterKeystrokeFull(args); + private getFormattingEditsAfterKeystroke(args); + private getCompletions(args, simplifiedResult); + private getCompletionEntryDetails(args); + private getCompileOnSaveAffectedFileList(args); + private emitFile(args); + private getSignatureHelpItems(args, simplifiedResult); + private getDiagnostics(delay, fileNames); + private change(args); + private reload(args, reqSeq); + private saveToTmp(fileName, tempFileName); + private closeClientFile(fileName); + private decorateNavigationBarItems(items, scriptInfo); + private getNavigationBarItems(args, simplifiedResult); + private decorateNavigationTree(tree, scriptInfo); + private decorateSpan(span, scriptInfo); + private getNavigationTree(args, simplifiedResult); + private getNavigateToItems(args, simplifiedResult); + private getSupportedCodeFixes(); + private getCodeFixes(args, simplifiedResult); + private mapCodeAction(codeAction, scriptInfo); + private convertTextChangeToCodeEdit(change, scriptInfo); + private getBraceMatching(args, simplifiedResult); + getDiagnosticsForProject(delay: number, fileName: string): void; + getCanonicalFileName(fileName: string): string; + exit(): void; + private notRequired(); + private requiredResponse(response); + private handlers; + addProtocolHandler(command: string, handler: (request: protocol.Request) => { + response?: any; + responseRequired: boolean; + }): void; + executeCommand(request: protocol.Request): { + response?: any; + responseRequired?: boolean; + }; + onMessage(message: string): void; + } +} +declare namespace ts.server { + function shouldEmitFile(scriptInfo: ScriptInfo): boolean; + class BuilderFileInfo { + readonly scriptInfo: ScriptInfo; + readonly project: Project; + private lastCheckedShapeSignature; + constructor(scriptInfo: ScriptInfo, project: Project); + isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; + private containsOnlyAmbientModules(sourceFile); + private computeHash(text); + private getSourceFile(); + updateShapeSignature(): boolean; + } + interface Builder { + readonly project: Project; + getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; + onProjectUpdateGraph(): void; + emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; + clear(): void; + } + function createBuilder(project: Project): Builder; +} + +export = ts; +export as namespace ts; \ No newline at end of file diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 459706962fb..ab1a5cdfe05 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -5924,388 +5924,6 @@ var ts; } })(ts || (ts = {})); var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - JsTyping.nodeCoreModuleList = [ - "buffer", "querystring", "events", "http", "cluster", - "zlib", "os", "https", "punycode", "repl", "readline", - "vm", "child_process", "url", "dns", "net", - "dgram", "fs", "path", "string_decoder", "tls", - "crypto", "stream", "util", "assert", "tty", "domain", - "constants", "process", "v8", "timers", "console" - ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { - var inferredTypings = ts.createMap(); - if (!typeAcquisition || !typeAcquisition.enable) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typeAcquisition.include); - exclude = typeAcquisition.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - if (unresolvedImports) { - for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { - var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; - } - } - } - for (var name_6 in packageNameToTypingLocation) { - if (name_6 in inferredTypings && !inferredTypings[name_6]) { - inferredTypings[name_6] = packageNameToTypingLocation[name_6]; - } - } - for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { - var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - if (host.fileExists(jsonPath)) { - filesToWatch.push(jsonPath); - } - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.ActionSet = "action::set"; - server.ActionInvalidate = "action::invalidate"; - server.EventBeginInstallTypes = "event::beginInstallTypes"; - server.EventEndInstallTypes = "event::endInstallTypes"; - var Arguments; - (function (Arguments) { - Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; - Arguments.LogFile = "--logFile"; - Arguments.EnableTelemetry = "--enableTelemetry"; - })(Arguments = server.Arguments || (server.Arguments = {})); - function hasArgument(argumentName) { - return ts.sys.args.indexOf(argumentName) >= 0; - } - server.hasArgument = hasArgument; - function findArgument(argumentName) { - var index = ts.sys.args.indexOf(argumentName); - return index >= 0 && index < ts.sys.args.length - 1 - ? ts.sys.args[index + 1] - : undefined; - } - server.findArgument = findArgument; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(LogLevel = server.LogLevel || (server.LogLevel = {})); - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(true), - compilerOptions: project.getCompilerOptions(), - typeAcquisition: typeAcquisition, - unresolvedImports: unresolvedImports, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - 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, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - function toSortedReadonlyArray(arr) { - arr.sort(); - return arr; - } - server.toSortedReadonlyArray = toSortedReadonlyArray; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); @@ -7723,9 +7341,9 @@ var ts; return; default: if (isFunctionLike(node)) { - var name_7 = node.name; - if (name_7 && name_7.kind === 142) { - traverse(name_7.expression); + var name_6 = node.name; + if (name_6 && name_6.kind === 142) { + traverse(name_6.expression); return; } } @@ -8404,8 +8022,8 @@ var ts; } } else if (param.name.kind === 70) { - var name_8 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_8; }); + var name_7 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 282 && tag.parameterName.text === name_7; }); } else { return undefined; @@ -9866,9 +9484,9 @@ var ts; if (syntaxKindCache[kind]) { return syntaxKindCache[kind]; } - for (var name_9 in syntaxKindEnum) { - if (syntaxKindEnum[name_9] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; + for (var name_8 in syntaxKindEnum) { + if (syntaxKindEnum[name_8] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_8 + ")"; } } } @@ -12590,15 +12208,15 @@ var ts; ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_10 = getMutableClone(node.name); + var name_9 = getMutableClone(node.name); emitFlags |= getEmitFlags(node.name); if (!allowSourceMaps) emitFlags |= 48; if (!allowComments) emitFlags |= 1536; if (emitFlags) - setEmitFlags(name_10, emitFlags); - return name_10; + setEmitFlags(name_9, emitFlags); + return name_9; } return getGeneratedNameForNode(node); } @@ -13179,8 +12797,8 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_11 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_10 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_10) ? name_10 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } if (node.kind === 236 && node.importClause) { return getGeneratedNameForNode(node); @@ -13424,10 +13042,10 @@ var ts; for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; if (!uniqueExports[specifier.name.text]) { - var name_12 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_12.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_12) - || resolver.getReferencedValueDeclaration(name_12); + var name_11 = specifier.propertyName || specifier.name; + ts.multiMapAdd(exportSpecifiers, name_11.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name_11) + || resolver.getReferencedValueDeclaration(name_11); if (decl) { ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } @@ -13459,11 +13077,11 @@ var ts; } } else { - var name_13 = node.name; - if (!uniqueExports[name_13.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_13); - uniqueExports[name_13.text] = true; - exportedNames = ts.append(exportedNames, name_13); + var name_12 = node.name; + if (!uniqueExports[name_12.text]) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); + uniqueExports[name_12.text] = true; + exportedNames = ts.append(exportedNames, name_12); } } } @@ -13477,11 +13095,11 @@ var ts; } } else { - var name_14 = node.name; - if (!uniqueExports[name_14.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_14); - uniqueExports[name_14.text] = true; - exportedNames = ts.append(exportedNames, name_14); + var name_13 = node.name; + if (!uniqueExports[name_13.text]) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_13); + uniqueExports[name_13.text] = true; + exportedNames = ts.append(exportedNames, name_13); } } } @@ -17275,8 +16893,8 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_15 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_15, undefined); + var name_14 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_14, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } @@ -18323,8 +17941,8 @@ var ts; if (typeExpression.type.kind === 273) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_16 = jsDocTypeReference.name; - if (name_16.text === "Object") { + var name_15 = jsDocTypeReference.name; + if (name_15.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -18428,14 +18046,14 @@ var ts; } var typeParameters = createNodeArray(); while (true) { - var name_17 = parseJSDocIdentifierName(); + var name_16 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_17) { + if (!name_16) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_17.pos); - typeParameter.name = name_17; + var typeParameter = createNode(143, name_16.pos); + typeParameter.name = name_16; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -22144,28 +21762,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_18 = specifier.propertyName || specifier.name; - if (name_18.text) { + var name_17 = specifier.propertyName || specifier.name; + if (name_17.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_18.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_17.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_18.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_17.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_18.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_18.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_17.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_17.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_18, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_18)); + error(name_17, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_17)); } return symbol; } @@ -23668,8 +23286,8 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_19 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_19)] = true; + var name_18 = properties_2[_i]; + names[ts.getTextOfPropertyName(name_18)] = true; } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; @@ -23714,19 +23332,19 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_20 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_20)) { + var name_19 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_19)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name_19); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_20)); + error(name_19, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_19)); return unknownType; } } @@ -30037,11 +29655,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_21 = declaration.propertyName || declaration.name; + var name_20 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_21)) { - var text = ts.getTextOfPropertyName(name_21); + !ts.isBindingPattern(name_20)) { + var text = ts.getTextOfPropertyName(name_20); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -32586,14 +32204,14 @@ var ts; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { if (property.kind === 258 || property.kind === 259) { - var name_22 = property.name; - if (name_22.kind === 142) { - checkComputedPropertyName(name_22); + var name_21 = property.name; + if (name_21.kind === 142) { + checkComputedPropertyName(name_21); } - if (isComputedNonLiteralName(name_22)) { + if (isComputedNonLiteralName(name_21)) { return undefined; } - var text = ts.getTextOfPropertyName(name_22); + var text = ts.getTextOfPropertyName(name_21); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -32608,7 +32226,7 @@ var ts; } } else { - error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); + error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_21)); } } else if (property.kind === 260) { @@ -33286,9 +32904,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_23 = _a[_i].name; - if (ts.isBindingPattern(name_23) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, parameterName, typePredicate.parameterName)) { + var name_22 = _a[_i].name; + if (ts.isBindingPattern(name_22) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -33320,15 +32938,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_24 = element.name; - if (name_24.kind === 70 && - name_24.text === predicateVariableName) { + var name_23 = element.name; + if (name_23.kind === 70 && + name_23.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_24.kind === 173 || - name_24.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, predicateVariableNode, predicateVariableName)) { + else if (name_23.kind === 173 || + name_23.kind === 172) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, predicateVariableNode, predicateVariableName)) { return true; } } @@ -34538,8 +34156,8 @@ var ts; container.kind === 231 || container.kind === 262); if (!namesShareScope) { - var name_25 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); + var name_24 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_24, name_24); } } } @@ -34616,8 +34234,8 @@ var ts; } var parent_11 = node.parent.parent; var parentType = getTypeForBindingElementParent(parent_11); - var name_26 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); + var name_25 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); markPropertyAsReferenced(property); if (parent_11.initializer && property && getParentOfSymbol(property)) { checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); @@ -35843,9 +35461,9 @@ var ts; break; case 174: case 224: - var name_27 = node.name; - if (ts.isBindingPattern(name_27)) { - for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { + var name_26 = node.name; + if (ts.isBindingPattern(name_26)) { + for (var _b = 0, _c = name_26.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } @@ -36727,9 +36345,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_28 = symbol.name; + var name_27 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_28); + var symbol = getPropertyOfType(t, name_27); if (symbol) { symbols_3.push(symbol); } @@ -37273,10 +36891,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 128; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_29 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_29), 107455); + var name_28 = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_28), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_29); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_28); } } } @@ -37825,9 +37443,9 @@ var ts; if (prop.kind === 260) { continue; } - var name_30 = prop.name; - if (name_30.kind === 142) { - checkGrammarComputedPropertyName(name_30); + var name_29 = prop.name; + if (name_29.kind === 142) { + checkGrammarComputedPropertyName(name_29); } if (prop.kind === 259 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -37843,8 +37461,8 @@ var ts; var currentKind = void 0; if (prop.kind === 258 || prop.kind === 259) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_30.kind === 8) { - checkGrammarNumericLiteral(name_30); + if (name_29.kind === 8) { + checkGrammarNumericLiteral(name_29); } currentKind = Property; } @@ -37860,7 +37478,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_29); if (effectiveName === undefined) { continue; } @@ -37870,18 +37488,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); + grammarErrorOnNode(name_29, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_29)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -37894,12 +37512,12 @@ var ts; continue; } var jsxAttr = attr; - var name_31 = jsxAttr.name; - if (!seen[name_31.text]) { - seen[name_31.text] = true; + var name_30 = jsxAttr.name; + if (!seen[name_30.text]) { + seen[name_30.text] = true; } else { - return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 253 && !initializer.expression) { @@ -39238,10 +38856,10 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_32 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_32, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_31 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name_31, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); variable.original = original; - if (ts.isIdentifier(name_32)) { + if (ts.isIdentifier(name_31)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -39387,8 +39005,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_33 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_33); + var name_32 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name_32); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -40311,14 +39929,14 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_34 = ts.getMutableClone(node); - name_34.flags &= ~8; - name_34.original = undefined; - name_34.parent = currentScope; + var name_33 = ts.getMutableClone(node); + name_33.flags &= ~8; + name_33.original = undefined; + name_33.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_34), ts.createLiteral("undefined")), name_34); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); } - return name_34; + return name_33; case 141: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -40589,9 +40207,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_35 = node.symbol && node.symbol.name; - if (name_35) { - return currentScopeFirstDeclarationsOfName[name_35] === node; + var name_34 = node.symbol && node.symbol.name; + if (name_34) { + return currentScopeFirstDeclarationsOfName[name_34] === node; } } return false; @@ -40880,14 +40498,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_36 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_36); + var name_35 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_35); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_36, initializer, node); + return ts.createPropertyAssignment(name_35, initializer, node); } - return ts.createPropertyAssignment(name_36, exportedName, node); + return ts.createPropertyAssignment(name_35, exportedName, node); } } return node; @@ -41411,12 +41029,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_37 = node.tagName; - if (ts.isIdentifier(name_37) && ts.isIntrinsicJsxName(name_37.text)) { - return ts.createLiteral(name_37.text); + var name_36 = node.tagName; + if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { + return ts.createLiteral(name_36.text); } else { - return ts.createExpressionFromEntityName(name_37); + return ts.createExpressionFromEntityName(name_36); } } } @@ -42505,15 +42123,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); + if (ts.isBindingPattern(name_37)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); } } } @@ -44295,9 +43913,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - var name_39 = ts.getSynthesizedClone(variable.name); - ts.setCommentRange(name_39, variable.name); - hoistVariableDeclaration(name_39); + var name_38 = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name_38, variable.name); + hoistVariableDeclaration(name_38); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -44692,9 +44310,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_40 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_40) { - var clone_7 = ts.getMutableClone(name_40); + var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_39) { + var clone_7 = ts.getMutableClone(name_39); ts.setSourceMapRange(clone_7, node); ts.setCommentRange(clone_7, node); return clone_7; @@ -46024,8 +45642,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_41 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_41), node); + var name_40 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); } } } @@ -47636,9 +47254,9 @@ var ts; var count = 0; while (true) { count++; - var name_42 = baseName + "_" + count; - if (!(name_42 in currentIdentifiers)) { - return name_42; + var name_41 = baseName + "_" + count; + if (!(name_41 in currentIdentifiers)) { + return name_41; } } } @@ -51160,21 +50778,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_43 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_43)) { + var name_42 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_42)) { tempFlags |= flags; - return name_43; + return name_42; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_44 = count < 26 + var name_43 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_44)) { - return name_44; + if (isUniqueName(name_43)) { + return name_43; } } } @@ -51524,10 +51142,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_45 = names_1[_i]; - var result = name_45 in cache - ? cache[name_45] - : cache[name_45] = loader(name_45, containingFile); + var name_44 = names_1[_i]; + var result = name_44 in cache + ? cache[name_44] + : cache[name_44] = loader(name_44, containingFile); resolutions.push(result); } return resolutions; @@ -55226,13 +54844,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_46 in nameTable) { - if (nameTable[name_46] === position) { + for (var name_45 in nameTable) { + if (nameTable[name_45] === position) { continue; } - if (!uniqueNames[name_46]) { - uniqueNames[name_46] = name_46; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); + if (!uniqueNames[name_45]) { + uniqueNames[name_45] = name_45; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -56308,8 +55926,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_47 = element.propertyName || element.name; - existingImportsOrExports[name_47.text] = true; + var name_46 = element.propertyName || element.name; + existingImportsOrExports[name_46.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -58439,6 +58057,167 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { + var inferredTypings = ts.createMap(); + if (!typeAcquisition || !typeAcquisition.enable) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typeAcquisition.include); + exclude = typeAcquisition.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = moduleId in nodeCoreModules ? "node" : moduleId; + if (!(typingName in inferredTypings)) { + inferredTypings[typingName] = undefined; + } + } + } + for (var name_47 in packageNameToTypingLocation) { + if (name_47 in inferredTypings && !inferredTypings[name_47]) { + inferredTypings[name_47] = packageNameToTypingLocation[name_47]; + } + } + for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { + var excludeTypingName = exclude_1[_b]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); + } + else { + newTypingNames.push(typing); + } + } + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!(typing in inferredTypings)) { + inferredTypings[typing] = undefined; + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings[packageJson.name] = absolutePath; + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { @@ -65709,6 +65488,1074 @@ var ts; initializeServices(); })(ts || (ts = {})); var ts; +(function (ts) { + var server; + (function (server) { + server.ActionSet = "action::set"; + server.ActionInvalidate = "action::invalidate"; + server.EventBeginInstallTypes = "event::beginInstallTypes"; + server.EventEndInstallTypes = "event::endInstallTypes"; + var Arguments; + (function (Arguments) { + Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments.LogFile = "--logFile"; + Arguments.EnableTelemetry = "--enableTelemetry"; + })(Arguments = server.Arguments || (server.Arguments = {})); + function hasArgument(argumentName) { + return ts.sys.args.indexOf(argumentName) >= 0; + } + server.hasArgument = hasArgument; + function findArgument(argumentName) { + var index = ts.sys.args.indexOf(argumentName); + return index >= 0 && index < ts.sys.args.length - 1 + ? ts.sys.args[index + 1] + : undefined; + } + server.findArgument = findArgument; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(true), + compilerOptions: project.getCompilerOptions(), + typeAcquisition: typeAcquisition, + unresolvedImports: unresolvedImports, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + 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, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + function toSortedReadonlyArray(arr) { + arr.sort(); + return arr; + } + server.toSortedReadonlyArray = toSortedReadonlyArray; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var lineCollectionCapacity = 4; + var CharRangeSection; + (function (CharRangeSection) { + CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; + CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; + CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; + CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; + CharRangeSection[CharRangeSection["End"] = 4] = "End"; + CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; + })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); + var BaseLineIndexWalker = (function () { + function BaseLineIndexWalker() { + this.goSubtree = true; + this.done = false; + } + BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { + }; + return BaseLineIndexWalker; + }()); + var EditWalker = (function (_super) { + __extends(EditWalker, _super); + function EditWalker() { + var _this = _super.call(this) || this; + _this.lineIndex = new LineIndex(); + _this.endBranch = []; + _this.state = CharRangeSection.Entire; + _this.initialText = ""; + _this.trailingText = ""; + _this.suppressTrailingText = false; + _this.lineIndex.root = new LineNode(); + _this.startPath = [_this.lineIndex.root]; + _this.stack = [_this.lineIndex.root]; + return _this; + } + EditWalker.prototype.insertLines = function (insertedText) { + if (this.suppressTrailingText) { + this.trailingText = ""; + } + if (insertedText) { + insertedText = this.initialText + insertedText + this.trailingText; + } + else { + insertedText = this.initialText + this.trailingText; + } + var lm = LineIndex.linesFromText(insertedText); + var lines = lm.lines; + if (lines.length > 1) { + if (lines[lines.length - 1] == "") { + lines.length--; + } + } + var branchParent; + var lastZeroCount; + for (var k = this.endBranch.length - 1; k >= 0; k--) { + this.endBranch[k].updateCounts(); + if (this.endBranch[k].charCount() === 0) { + lastZeroCount = this.endBranch[k]; + if (k > 0) { + branchParent = this.endBranch[k - 1]; + } + else { + branchParent = this.branchNode; + } + } + } + if (lastZeroCount) { + branchParent.remove(lastZeroCount); + } + var insertionNode = this.startPath[this.startPath.length - 2]; + var leafNode = this.startPath[this.startPath.length - 1]; + var len = lines.length; + if (len > 0) { + leafNode.text = lines[0]; + if (len > 1) { + var insertedNodes = new Array(len - 1); + var startNode = leafNode; + for (var i = 1; i < lines.length; i++) { + insertedNodes[i - 1] = new LineLeaf(lines[i]); + } + var pathIndex = this.startPath.length - 2; + while (pathIndex >= 0) { + insertionNode = this.startPath[pathIndex]; + insertedNodes = insertionNode.insertAt(startNode, insertedNodes); + pathIndex--; + startNode = insertionNode; + } + var insertedNodesLen = insertedNodes.length; + while (insertedNodesLen > 0) { + var newRoot = new LineNode(); + newRoot.add(this.lineIndex.root); + insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); + insertedNodesLen = insertedNodes.length; + this.lineIndex.root = newRoot; + } + this.lineIndex.root.updateCounts(); + } + else { + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + } + else { + insertionNode.remove(leafNode); + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } + } + return this.lineIndex; + }; + EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { + if (lineCollection === this.lineCollectionAtBranch) { + this.state = CharRangeSection.End; + } + this.stack.length--; + return undefined; + }; + EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { + var currentNode = this.stack[this.stack.length - 1]; + if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { + this.state = CharRangeSection.Start; + this.branchNode = currentNode; + this.lineCollectionAtBranch = lineCollection; + } + var child; + function fresh(node) { + if (node.isLeaf()) { + return new LineLeaf(""); + } + else + return new LineNode(); + } + switch (nodeType) { + case CharRangeSection.PreStart: + this.goSubtree = false; + if (this.state !== CharRangeSection.End) { + currentNode.add(lineCollection); + } + break; + case CharRangeSection.Start: + if (this.state === CharRangeSection.End) { + this.goSubtree = false; + } + else { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + break; + case CharRangeSection.Entire: + if (this.state !== CharRangeSection.End) { + child = fresh(lineCollection); + currentNode.add(child); + this.startPath[this.startPath.length] = child; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.Mid: + this.goSubtree = false; + break; + case CharRangeSection.End: + if (this.state !== CharRangeSection.End) { + this.goSubtree = false; + } + else { + if (!lineCollection.isLeaf()) { + child = fresh(lineCollection); + currentNode.add(child); + this.endBranch[this.endBranch.length] = child; + } + } + break; + case CharRangeSection.PostEnd: + this.goSubtree = false; + if (this.state !== CharRangeSection.Start) { + currentNode.add(lineCollection); + } + break; + } + if (this.goSubtree) { + this.stack[this.stack.length] = child; + } + return lineCollection; + }; + EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { + if (this.state === CharRangeSection.Start) { + this.initialText = ll.text.substring(0, relativeStart); + } + else if (this.state === CharRangeSection.Entire) { + this.initialText = ll.text.substring(0, relativeStart); + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + else { + this.trailingText = ll.text.substring(relativeStart + relativeLength); + } + }; + return EditWalker; + }(BaseLineIndexWalker)); + var TextChange = (function () { + function TextChange(pos, deleteLen, insertedText) { + this.pos = pos; + this.deleteLen = deleteLen; + this.insertedText = insertedText; + } + TextChange.prototype.getTextChangeRange = function () { + return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); + }; + return TextChange; + }()); + server.TextChange = TextChange; + var ScriptVersionCache = (function () { + function ScriptVersionCache() { + this.changes = []; + this.versions = new Array(ScriptVersionCache.maxVersions); + this.minVersion = 0; + this.currentVersion = 0; + } + ScriptVersionCache.prototype.versionToIndex = function (version) { + if (version < this.minVersion || version > this.currentVersion) { + return undefined; + } + return version % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.currentVersionToIndex = function () { + return this.currentVersion % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { + this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); + if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || + (deleteLen > ScriptVersionCache.changeLengthThreshold) || + (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { + this.getSnapshot(); + } + }; + ScriptVersionCache.prototype.latest = function () { + return this.versions[this.currentVersionToIndex()]; + }; + ScriptVersionCache.prototype.latestVersion = function () { + if (this.changes.length > 0) { + this.getSnapshot(); + } + return this.currentVersion; + }; + ScriptVersionCache.prototype.reloadFromFile = function (filename) { + var content = this.host.readFile(filename); + if (!content) { + content = ""; + } + this.reload(content); + }; + ScriptVersionCache.prototype.reload = function (script) { + this.currentVersion++; + this.changes = []; + var snap = new LineIndexSnapshot(this.currentVersion, this); + for (var i = 0; i < this.versions.length; i++) { + this.versions[i] = undefined; + } + this.versions[this.currentVersionToIndex()] = snap; + snap.index = new LineIndex(); + var lm = LineIndex.linesFromText(script); + snap.index.load(lm.lines); + this.minVersion = this.currentVersion; + }; + ScriptVersionCache.prototype.getSnapshot = function () { + var snap = this.versions[this.currentVersionToIndex()]; + if (this.changes.length > 0) { + var snapIndex = snap.index; + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var change = _a[_i]; + snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); + } + snap = new LineIndexSnapshot(this.currentVersion + 1, this); + snap.index = snapIndex; + snap.changesSincePreviousVersion = this.changes; + this.currentVersion = snap.version; + this.versions[this.currentVersionToIndex()] = snap; + this.changes = []; + if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { + this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; + } + } + return snap; + }; + ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { + if (oldVersion < newVersion) { + if (oldVersion >= this.minVersion) { + var textChangeRanges = []; + for (var i = oldVersion + 1; i <= newVersion; i++) { + var snap = this.versions[this.versionToIndex(i)]; + for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { + var textChange = _a[_i]; + textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); + } + } + return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); + } + else { + return undefined; + } + } + else { + return ts.unchangedTextChangeRange; + } + }; + ScriptVersionCache.fromString = function (host, script) { + var svc = new ScriptVersionCache(); + var snap = new LineIndexSnapshot(0, svc); + svc.versions[svc.currentVersion] = snap; + svc.host = host; + snap.index = new LineIndex(); + var lm = LineIndex.linesFromText(script); + snap.index.load(lm.lines); + return svc; + }; + return ScriptVersionCache; + }()); + ScriptVersionCache.changeNumberThreshold = 8; + ScriptVersionCache.changeLengthThreshold = 256; + ScriptVersionCache.maxVersions = 8; + server.ScriptVersionCache = ScriptVersionCache; + var LineIndexSnapshot = (function () { + function LineIndexSnapshot(version, cache) { + this.version = version; + this.cache = cache; + this.changesSincePreviousVersion = []; + } + LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { + return this.index.getText(rangeStart, rangeEnd - rangeStart); + }; + LineIndexSnapshot.prototype.getLength = function () { + return this.index.root.charCount(); + }; + LineIndexSnapshot.prototype.getLineStartPositions = function () { + var starts = [-1]; + var count = 1; + var pos = 0; + this.index.every(function (ll) { + starts[count] = pos; + count++; + pos += ll.text.length; + return true; + }, 0); + return starts; + }; + LineIndexSnapshot.prototype.getLineMapper = function () { + var _this = this; + return function (line) { + return _this.index.lineNumberToInfo(line).offset; + }; + }; + LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + if (this.version <= scriptVersion) { + return ts.unchangedTextChangeRange; + } + else { + return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); + } + }; + LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { + if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) { + return this.getTextChangeRangeSinceVersion(oldSnapshot.version); + } + }; + return LineIndexSnapshot; + }()); + server.LineIndexSnapshot = LineIndexSnapshot; + var LineIndex = (function () { + function LineIndex() { + this.checkEdits = false; + } + LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { + return this.root.charOffsetToLineNumberAndPos(1, charOffset); + }; + LineIndex.prototype.lineNumberToInfo = function (lineNumber) { + var lineCount = this.root.lineCount(); + if (lineNumber <= lineCount) { + var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); + lineInfo.line = lineNumber; + return lineInfo; + } + else { + return { + line: lineNumber, + offset: this.root.charCount() + }; + } + }; + LineIndex.prototype.load = function (lines) { + if (lines.length > 0) { + var leaves = []; + for (var i = 0; i < lines.length; i++) { + leaves[i] = new LineLeaf(lines[i]); + } + this.root = LineIndex.buildTreeFromBottom(leaves); + } + else { + this.root = new LineNode(); + } + }; + LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { + this.root.walk(rangeStart, rangeLength, walkFns); + }; + LineIndex.prototype.getText = function (rangeStart, rangeLength) { + var accum = ""; + if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { + this.walk(rangeStart, rangeLength, { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); + } + }); + } + return accum; + }; + LineIndex.prototype.getLength = function () { + return this.root.charCount(); + }; + LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { + if (!rangeEnd) { + rangeEnd = this.root.charCount(); + } + var walkFns = { + goSubtree: true, + done: false, + leaf: function (relativeStart, relativeLength, ll) { + if (!f(ll, relativeStart, relativeLength)) { + this.done = true; + } + } + }; + this.walk(rangeStart, rangeEnd - rangeStart, walkFns); + return !walkFns.done; + }; + LineIndex.prototype.edit = function (pos, deleteLength, newText) { + function editFlat(source, s, dl, nt) { + if (nt === void 0) { nt = ""; } + return source.substring(0, s) + nt + source.substring(s + dl, source.length); + } + if (this.root.charCount() === 0) { + if (newText !== undefined) { + this.load(LineIndex.linesFromText(newText).lines); + return this; + } + } + else { + var checkText = void 0; + if (this.checkEdits) { + checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); + } + var walker = new EditWalker(); + if (pos >= this.root.charCount()) { + pos = this.root.charCount() - 1; + var endString = this.getText(pos, 1); + if (newText) { + newText = endString + newText; + } + else { + newText = endString; + } + deleteLength = 0; + walker.suppressTrailingText = true; + } + else if (deleteLength > 0) { + var e = pos + deleteLength; + var lineInfo = this.charOffsetToLineNumberAndPos(e); + if ((lineInfo && (lineInfo.offset === 0))) { + deleteLength += lineInfo.text.length; + if (newText) { + newText = newText + lineInfo.text; + } + else { + newText = lineInfo.text; + } + } + } + if (pos < this.root.charCount()) { + this.root.walk(pos, deleteLength, walker); + walker.insertLines(newText); + } + if (this.checkEdits) { + var updatedText = this.getText(0, this.root.charCount()); + ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); + } + return walker.lineIndex; + } + }; + LineIndex.buildTreeFromBottom = function (nodes) { + var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); + var interiorNodes = []; + var nodeIndex = 0; + for (var i = 0; i < nodeCount; i++) { + interiorNodes[i] = new LineNode(); + var charCount = 0; + var lineCount = 0; + for (var j = 0; j < lineCollectionCapacity; j++) { + if (nodeIndex < nodes.length) { + interiorNodes[i].add(nodes[nodeIndex]); + charCount += nodes[nodeIndex].charCount(); + lineCount += nodes[nodeIndex].lineCount(); + } + else { + break; + } + nodeIndex++; + } + interiorNodes[i].totalChars = charCount; + interiorNodes[i].totalLines = lineCount; + } + if (interiorNodes.length === 1) { + return interiorNodes[0]; + } + else { + return this.buildTreeFromBottom(interiorNodes); + } + }; + LineIndex.linesFromText = function (text) { + var lineStarts = ts.computeLineStarts(text); + if (lineStarts.length === 0) { + return { lines: [], lineMap: lineStarts }; + } + var lines = new Array(lineStarts.length); + var lc = lineStarts.length - 1; + for (var lmi = 0; lmi < lc; lmi++) { + lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); + } + var endText = text.substring(lineStarts[lc]); + if (endText.length > 0) { + lines[lc] = endText; + } + else { + lines.length--; + } + return { lines: lines, lineMap: lineStarts }; + }; + return LineIndex; + }()); + server.LineIndex = LineIndex; + var LineNode = (function () { + function LineNode() { + this.totalChars = 0; + this.totalLines = 0; + this.children = []; + } + LineNode.prototype.isLeaf = function () { + return false; + }; + LineNode.prototype.updateCounts = function () { + this.totalChars = 0; + this.totalLines = 0; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; + this.totalChars += child.charCount(); + this.totalLines += child.lineCount(); + } + }; + LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { + if (walkFns.pre) { + walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + if (walkFns.goSubtree) { + this.children[childIndex].walk(rangeStart, rangeLength, walkFns); + if (walkFns.post) { + walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + } + } + else { + walkFns.goSubtree = true; + } + return walkFns.done; + }; + LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { + if (walkFns.pre && (!walkFns.done)) { + walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); + walkFns.goSubtree = true; + } + }; + LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { + var childIndex = 0; + var child = this.children[0]; + var childCharCount = child.charCount(); + var adjustedStart = rangeStart; + while (adjustedStart >= childCharCount) { + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); + adjustedStart -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if ((adjustedStart + rangeLength) <= childCharCount) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { + return; + } + } + else { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { + return; + } + var adjustedLength = rangeLength - (childCharCount - adjustedStart); + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + while (adjustedLength > childCharCount) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { + return; + } + adjustedLength -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if (adjustedLength > 0) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { + return; + } + } + } + if (walkFns.pre) { + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var ej = childIndex + 1; ej < clen; ej++) { + this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); + } + } + } + }; + LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { + var childInfo = this.childFromCharOffset(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset, + }; + } + else if (childInfo.childIndex < this.children.length) { + if (childInfo.child.isLeaf()) { + return { + line: childInfo.lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); + } + } + else { + var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); + return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; + } + }; + LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { + var childInfo = this.childFromLineNumber(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset + }; + } + else if (childInfo.child.isLeaf()) { + return { + line: lineNumber, + offset: childInfo.charOffset, + text: (childInfo.child).text, + leaf: (childInfo.child) + }; + } + else { + var lineNode = (childInfo.child); + return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); + } + }; + LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { + var child; + var relativeLineNumber = lineNumber; + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + var childLineCount = child.lineCount(); + if (childLineCount >= relativeLineNumber) { + break; + } + else { + relativeLineNumber -= childLineCount; + charOffset += child.charCount(); + } + } + return { + child: child, + childIndex: i, + relativeLineNumber: relativeLineNumber, + charOffset: charOffset + }; + }; + LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { + var child; + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { + child = this.children[i]; + if (child.charCount() > charOffset) { + break; + } + else { + charOffset -= child.charCount(); + lineNumber += child.lineCount(); + } + } + return { + child: child, + childIndex: i, + charOffset: charOffset, + lineNumber: lineNumber + }; + }; + LineNode.prototype.splitAfter = function (childIndex) { + var splitNode; + var clen = this.children.length; + childIndex++; + var endLength = childIndex; + if (childIndex < clen) { + splitNode = new LineNode(); + while (childIndex < clen) { + splitNode.add(this.children[childIndex]); + childIndex++; + } + splitNode.updateCounts(); + } + this.children.length = endLength; + return splitNode; + }; + LineNode.prototype.remove = function (child) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + if (childIndex < (clen - 1)) { + for (var i = childIndex; i < (clen - 1); i++) { + this.children[i] = this.children[i + 1]; + } + } + this.children.length--; + }; + LineNode.prototype.findChildIndex = function (child) { + var childIndex = 0; + var clen = this.children.length; + while ((this.children[childIndex] !== child) && (childIndex < clen)) + childIndex++; + return childIndex; + }; + LineNode.prototype.insertAt = function (child, nodes) { + var childIndex = this.findChildIndex(child); + var clen = this.children.length; + var nodeCount = nodes.length; + if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { + this.add(nodes[0]); + this.updateCounts(); + return []; + } + else { + var shiftNode = this.splitAfter(childIndex); + var nodeIndex = 0; + childIndex++; + while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { + this.children[childIndex] = nodes[nodeIndex]; + childIndex++; + nodeIndex++; + } + var splitNodes = []; + var splitNodeCount = 0; + if (nodeIndex < nodeCount) { + splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); + splitNodes = new Array(splitNodeCount); + var splitNodeIndex = 0; + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i] = new LineNode(); + } + var splitNode = splitNodes[0]; + while (nodeIndex < nodeCount) { + splitNode.add(nodes[nodeIndex]); + nodeIndex++; + if (splitNode.children.length === lineCollectionCapacity) { + splitNodeIndex++; + splitNode = splitNodes[splitNodeIndex]; + } + } + for (var i = splitNodes.length - 1; i >= 0; i--) { + if (splitNodes[i].children.length === 0) { + splitNodes.length--; + } + } + } + if (shiftNode) { + splitNodes[splitNodes.length] = shiftNode; + } + this.updateCounts(); + for (var i = 0; i < splitNodeCount; i++) { + splitNodes[i].updateCounts(); + } + return splitNodes; + } + }; + LineNode.prototype.add = function (collection) { + this.children[this.children.length] = collection; + return (this.children.length < lineCollectionCapacity); + }; + LineNode.prototype.charCount = function () { + return this.totalChars; + }; + LineNode.prototype.lineCount = function () { + return this.totalLines; + }; + return LineNode; + }()); + server.LineNode = LineNode; + var LineLeaf = (function () { + function LineLeaf(text) { + this.text = text; + } + LineLeaf.prototype.isLeaf = function () { + return true; + }; + LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { + walkFns.leaf(rangeStart, rangeLength, this); + }; + LineLeaf.prototype.charCount = function () { + return this.text.length; + }; + LineLeaf.prototype.lineCount = function () { + return 1; + }; + return LineLeaf; + }()); + server.LineLeaf = LineLeaf; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var server; (function (server) { @@ -66276,314 +67123,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; - } - server.shouldEmitFile = shouldEmitFile; - var BuilderFileInfo = (function () { - function BuilderFileInfo(scriptInfo, project) { - this.scriptInfo = scriptInfo; - this.project = project; - } - BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { - var sourceFile = this.getSourceFile(); - return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); - }; - BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (statement.kind !== 231 || statement.name.kind !== 9) { - return false; - } - } - return true; - }; - BuilderFileInfo.prototype.computeHash = function (text) { - return this.project.projectService.host.createHash(text); - }; - BuilderFileInfo.prototype.getSourceFile = function () { - return this.project.getSourceFile(this.scriptInfo.path); - }; - BuilderFileInfo.prototype.updateShapeSignature = function () { - var sourceFile = this.getSourceFile(); - if (!sourceFile) { - return true; - } - var lastSignature = this.lastCheckedShapeSignature; - if (sourceFile.isDeclarationFile) { - this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); - } - else { - var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); - } - } - return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; - }; - return BuilderFileInfo; - }()); - server.BuilderFileInfo = BuilderFileInfo; - var AbstractBuilder = (function () { - function AbstractBuilder(project, ctor) { - this.project = project; - this.ctor = ctor; - } - AbstractBuilder.prototype.getFileInfos = function () { - return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); - }; - AbstractBuilder.prototype.clear = function () { - this.fileInfos_doNotAccessDirectly = undefined; - }; - AbstractBuilder.prototype.getFileInfo = function (path) { - return this.getFileInfos().get(path); - }; - AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { - var fileInfo = this.getFileInfo(path); - if (!fileInfo) { - var scriptInfo = this.project.getScriptInfo(path); - fileInfo = new this.ctor(scriptInfo, this.project); - this.setFileInfo(path, fileInfo); - } - return fileInfo; - }; - AbstractBuilder.prototype.getFileInfoPaths = function () { - return this.getFileInfos().getKeys(); - }; - AbstractBuilder.prototype.setFileInfo = function (path, info) { - this.getFileInfos().set(path, info); - }; - AbstractBuilder.prototype.removeFileInfo = function (path) { - this.getFileInfos().remove(path); - }; - AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); - }; - AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo) { - return false; - } - var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; - if (!emitSkipped) { - var projectRootPath = this.project.getProjectRootPath(); - for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { - var outputFile = outputFiles_1[_i]; - var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); - writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); - } - } - return !emitSkipped; - }; - return AbstractBuilder; - }()); - var NonModuleBuilder = (function (_super) { - __extends(NonModuleBuilder, _super); - function NonModuleBuilder(project) { - var _this = _super.call(this, project, BuilderFileInfo) || this; - _this.project = project; - return _this; - } - NonModuleBuilder.prototype.onProjectUpdateGraph = function () { - }; - NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - var info = this.getOrCreateFileInfo(scriptInfo.path); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - if (info.updateShapeSignature()) { - var options = this.project.getCompilerOptions(); - if (options && (options.out || options.outFile)) { - return singleFileResult; - } - return this.project.getAllEmittableFiles(); - } - return singleFileResult; - }; - return NonModuleBuilder; - }(AbstractBuilder)); - var ModuleBuilderFileInfo = (function (_super) { - __extends(ModuleBuilderFileInfo, _super); - function ModuleBuilderFileInfo() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.references = []; - _this.referencedBy = []; - return _this; - } - ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { - var l = lf.scriptInfo.fileName; - var r = rf.scriptInfo.fileName; - return (l < r ? -1 : (l > r ? 1 : 0)); - }; - ; - ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { - if (array.length === 0) { - array.push(fileInfo); - return; - } - var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (insertIndex < 0) { - array.splice(~insertIndex, 0, fileInfo); - } - }; - ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { - if (!array || array.length === 0) { - return; - } - if (array[0] === fileInfo) { - array.splice(0, 1); - return; - } - var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (removeIndex >= 0) { - array.splice(removeIndex, 1); - } - }; - ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeFileReferences = function () { - for (var _i = 0, _a = this.references; _i < _a.length; _i++) { - var reference = _a[_i]; - reference.removeReferencedBy(this); - } - this.references = []; - }; - return ModuleBuilderFileInfo; - }(BuilderFileInfo)); - var ModuleBuilder = (function (_super) { - __extends(ModuleBuilder, _super); - function ModuleBuilder(project) { - var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; - _this.project = project; - return _this; - } - ModuleBuilder.prototype.clear = function () { - this.projectVersionForDependencyGraph = undefined; - _super.prototype.clear.call(this); - }; - ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { - var _this = this; - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return []; - } - var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); - if (referencedFilePaths.length > 0) { - return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); - } - return []; - }; - ModuleBuilder.prototype.onProjectUpdateGraph = function () { - this.ensureProjectDependencyGraphUpToDate(); - }; - ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { - var _this = this; - if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { - var currentScriptInfos = this.project.getScriptInfos(); - for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { - var scriptInfo = currentScriptInfos_1[_i]; - var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); - this.updateFileReferences(fileInfo); - } - this.forEachFileInfo(function (fileInfo) { - if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { - fileInfo.removeFileReferences(); - _this.removeFileInfo(fileInfo.scriptInfo.path); - } - }); - this.projectVersionForDependencyGraph = this.project.getProjectVersion(); - } - }; - ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { - if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { - return; - } - var newReferences = this.getReferencedFileInfos(fileInfo); - var oldReferences = fileInfo.references; - var oldIndex = 0; - var newIndex = 0; - while (oldIndex < oldReferences.length && newIndex < newReferences.length) { - var oldReference = oldReferences[oldIndex]; - var newReference = newReferences[newIndex]; - var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); - if (compare < 0) { - oldReference.removeReferencedBy(fileInfo); - oldIndex++; - } - else if (compare > 0) { - newReference.addReferencedBy(fileInfo); - newIndex++; - } - else { - oldIndex++; - newIndex++; - } - } - for (var i = oldIndex; i < oldReferences.length; i++) { - oldReferences[i].removeReferencedBy(fileInfo); - } - for (var i = newIndex; i < newReferences.length; i++) { - newReferences[i].addReferencedBy(fileInfo); - } - fileInfo.references = newReferences; - fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); - }; - ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - this.ensureProjectDependencyGraphUpToDate(); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo || !fileInfo.updateShapeSignature()) { - return singleFileResult; - } - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return this.project.getAllEmittableFiles(); - } - var options = this.project.getCompilerOptions(); - if (options && (options.isolatedModules || options.out || options.outFile)) { - return singleFileResult; - } - var queue = fileInfo.referencedBy.slice(0); - var fileNameSet = ts.createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; - while (queue.length > 0) { - var processingFileInfo = queue.pop(); - if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { - for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { - var potentialFileInfo = _a[_i]; - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { - queue.push(potentialFileInfo); - } - } - } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; - } - var result = []; - for (var fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { - result.push(fileName); - } - } - return result; - }; - return ModuleBuilder; - }(AbstractBuilder)); - function createBuilder(project) { - var moduleKind = project.getCompilerOptions().module; - switch (moduleKind) { - case ts.ModuleKind.None: - return new NonModuleBuilder(project); - default: - return new ModuleBuilder(project); - } - } - server.createBuilder = createBuilder; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var server; (function (server) { @@ -69913,847 +70452,308 @@ var ts; (function (ts) { var server; (function (server) { - var lineCollectionCapacity = 4; - var CharRangeSection; - (function (CharRangeSection) { - CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; - CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; - CharRangeSection[CharRangeSection["Entire"] = 2] = "Entire"; - CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; - CharRangeSection[CharRangeSection["End"] = 4] = "End"; - CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); - var BaseLineIndexWalker = (function () { - function BaseLineIndexWalker() { - this.goSubtree = true; - this.done = false; + function shouldEmitFile(scriptInfo) { + return !scriptInfo.hasMixedContent; + } + server.shouldEmitFile = shouldEmitFile; + var BuilderFileInfo = (function () { + function BuilderFileInfo(scriptInfo, project) { + this.scriptInfo = scriptInfo; + this.project = project; } - BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { + BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { + var sourceFile = this.getSourceFile(); + return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); }; - return BaseLineIndexWalker; - }()); - var EditWalker = (function (_super) { - __extends(EditWalker, _super); - function EditWalker() { - var _this = _super.call(this) || this; - _this.lineIndex = new LineIndex(); - _this.endBranch = []; - _this.state = CharRangeSection.Entire; - _this.initialText = ""; - _this.trailingText = ""; - _this.suppressTrailingText = false; - _this.lineIndex.root = new LineNode(); - _this.startPath = [_this.lineIndex.root]; - _this.stack = [_this.lineIndex.root]; - return _this; - } - EditWalker.prototype.insertLines = function (insertedText) { - if (this.suppressTrailingText) { - this.trailingText = ""; - } - if (insertedText) { - insertedText = this.initialText + insertedText + this.trailingText; - } - else { - insertedText = this.initialText + this.trailingText; - } - var lm = LineIndex.linesFromText(insertedText); - var lines = lm.lines; - if (lines.length > 1) { - if (lines[lines.length - 1] == "") { - lines.length--; + BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement.kind !== 231 || statement.name.kind !== 9) { + return false; } } - var branchParent; - var lastZeroCount; - for (var k = this.endBranch.length - 1; k >= 0; k--) { - this.endBranch[k].updateCounts(); - if (this.endBranch[k].charCount() === 0) { - lastZeroCount = this.endBranch[k]; - if (k > 0) { - branchParent = this.endBranch[k - 1]; - } - else { - branchParent = this.branchNode; - } - } - } - if (lastZeroCount) { - branchParent.remove(lastZeroCount); - } - var insertionNode = this.startPath[this.startPath.length - 2]; - var leafNode = this.startPath[this.startPath.length - 1]; - var len = lines.length; - if (len > 0) { - leafNode.text = lines[0]; - if (len > 1) { - var insertedNodes = new Array(len - 1); - var startNode = leafNode; - for (var i = 1; i < lines.length; i++) { - insertedNodes[i - 1] = new LineLeaf(lines[i]); - } - var pathIndex = this.startPath.length - 2; - while (pathIndex >= 0) { - insertionNode = this.startPath[pathIndex]; - insertedNodes = insertionNode.insertAt(startNode, insertedNodes); - pathIndex--; - startNode = insertionNode; - } - var insertedNodesLen = insertedNodes.length; - while (insertedNodesLen > 0) { - var newRoot = new LineNode(); - newRoot.add(this.lineIndex.root); - insertedNodes = newRoot.insertAt(this.lineIndex.root, insertedNodes); - insertedNodesLen = insertedNodes.length; - this.lineIndex.root = newRoot; - } - this.lineIndex.root.updateCounts(); - } - else { - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - } - else { - insertionNode.remove(leafNode); - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); - } - } - return this.lineIndex; - }; - EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { - if (lineCollection === this.lineCollectionAtBranch) { - this.state = CharRangeSection.End; - } - this.stack.length--; - return undefined; - }; - EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { - var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { - this.state = CharRangeSection.Start; - this.branchNode = currentNode; - this.lineCollectionAtBranch = lineCollection; - } - var child; - function fresh(node) { - if (node.isLeaf()) { - return new LineLeaf(""); - } - else - return new LineNode(); - } - switch (nodeType) { - case CharRangeSection.PreStart: - this.goSubtree = false; - if (this.state !== CharRangeSection.End) { - currentNode.add(lineCollection); - } - break; - case CharRangeSection.Start: - if (this.state === CharRangeSection.End) { - this.goSubtree = false; - } - else { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - break; - case CharRangeSection.Entire: - if (this.state !== CharRangeSection.End) { - child = fresh(lineCollection); - currentNode.add(child); - this.startPath[this.startPath.length] = child; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.Mid: - this.goSubtree = false; - break; - case CharRangeSection.End: - if (this.state !== CharRangeSection.End) { - this.goSubtree = false; - } - else { - if (!lineCollection.isLeaf()) { - child = fresh(lineCollection); - currentNode.add(child); - this.endBranch[this.endBranch.length] = child; - } - } - break; - case CharRangeSection.PostEnd: - this.goSubtree = false; - if (this.state !== CharRangeSection.Start) { - currentNode.add(lineCollection); - } - break; - } - if (this.goSubtree) { - this.stack[this.stack.length] = child; - } - return lineCollection; - }; - EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === CharRangeSection.Start) { - this.initialText = ll.text.substring(0, relativeStart); - } - else if (this.state === CharRangeSection.Entire) { - this.initialText = ll.text.substring(0, relativeStart); - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - else { - this.trailingText = ll.text.substring(relativeStart + relativeLength); - } - }; - return EditWalker; - }(BaseLineIndexWalker)); - var TextChange = (function () { - function TextChange(pos, deleteLen, insertedText) { - this.pos = pos; - this.deleteLen = deleteLen; - this.insertedText = insertedText; - } - TextChange.prototype.getTextChangeRange = function () { - return ts.createTextChangeRange(ts.createTextSpan(this.pos, this.deleteLen), this.insertedText ? this.insertedText.length : 0); - }; - return TextChange; - }()); - server.TextChange = TextChange; - var ScriptVersionCache = (function () { - function ScriptVersionCache() { - this.changes = []; - this.versions = new Array(ScriptVersionCache.maxVersions); - this.minVersion = 0; - this.currentVersion = 0; - } - ScriptVersionCache.prototype.versionToIndex = function (version) { - if (version < this.minVersion || version > this.currentVersion) { - return undefined; - } - return version % ScriptVersionCache.maxVersions; - }; - ScriptVersionCache.prototype.currentVersionToIndex = function () { - return this.currentVersion % ScriptVersionCache.maxVersions; - }; - ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { - this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); - if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || - (deleteLen > ScriptVersionCache.changeLengthThreshold) || - (insertedText && (insertedText.length > ScriptVersionCache.changeLengthThreshold))) { - this.getSnapshot(); - } - }; - ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersionToIndex()]; - }; - ScriptVersionCache.prototype.latestVersion = function () { - if (this.changes.length > 0) { - this.getSnapshot(); - } - return this.currentVersion; - }; - ScriptVersionCache.prototype.reloadFromFile = function (filename) { - var content = this.host.readFile(filename); - if (!content) { - content = ""; - } - this.reload(content); - }; - ScriptVersionCache.prototype.reload = function (script) { - this.currentVersion++; - this.changes = []; - var snap = new LineIndexSnapshot(this.currentVersion, this); - for (var i = 0; i < this.versions.length; i++) { - this.versions[i] = undefined; - } - this.versions[this.currentVersionToIndex()] = snap; - snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); - snap.index.load(lm.lines); - this.minVersion = this.currentVersion; - }; - ScriptVersionCache.prototype.getSnapshot = function () { - var snap = this.versions[this.currentVersionToIndex()]; - if (this.changes.length > 0) { - var snapIndex = snap.index; - for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { - var change = _a[_i]; - snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); - } - snap = new LineIndexSnapshot(this.currentVersion + 1, this); - snap.index = snapIndex; - snap.changesSincePreviousVersion = this.changes; - this.currentVersion = snap.version; - this.versions[this.currentVersionToIndex()] = snap; - this.changes = []; - if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { - this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; - } - } - return snap; - }; - ScriptVersionCache.prototype.getTextChangesBetweenVersions = function (oldVersion, newVersion) { - if (oldVersion < newVersion) { - if (oldVersion >= this.minVersion) { - var textChangeRanges = []; - for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[this.versionToIndex(i)]; - for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { - var textChange = _a[_i]; - textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); - } - } - return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); - } - else { - return undefined; - } - } - else { - return ts.unchangedTextChangeRange; - } - }; - ScriptVersionCache.fromString = function (host, script) { - var svc = new ScriptVersionCache(); - var snap = new LineIndexSnapshot(0, svc); - svc.versions[svc.currentVersion] = snap; - svc.host = host; - snap.index = new LineIndex(); - var lm = LineIndex.linesFromText(script); - snap.index.load(lm.lines); - return svc; - }; - return ScriptVersionCache; - }()); - ScriptVersionCache.changeNumberThreshold = 8; - ScriptVersionCache.changeLengthThreshold = 256; - ScriptVersionCache.maxVersions = 8; - server.ScriptVersionCache = ScriptVersionCache; - var LineIndexSnapshot = (function () { - function LineIndexSnapshot(version, cache) { - this.version = version; - this.cache = cache; - this.changesSincePreviousVersion = []; - } - LineIndexSnapshot.prototype.getText = function (rangeStart, rangeEnd) { - return this.index.getText(rangeStart, rangeEnd - rangeStart); - }; - LineIndexSnapshot.prototype.getLength = function () { - return this.index.root.charCount(); - }; - LineIndexSnapshot.prototype.getLineStartPositions = function () { - var starts = [-1]; - var count = 1; - var pos = 0; - this.index.every(function (ll) { - starts[count] = pos; - count++; - pos += ll.text.length; - return true; - }, 0); - return starts; - }; - LineIndexSnapshot.prototype.getLineMapper = function () { - var _this = this; - return function (line) { - return _this.index.lineNumberToInfo(line).offset; - }; - }; - LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - if (this.version <= scriptVersion) { - return ts.unchangedTextChangeRange; - } - else { - return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); - } - }; - LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { - if (oldSnapshot instanceof LineIndexSnapshot && this.cache === oldSnapshot.cache) { - return this.getTextChangeRangeSinceVersion(oldSnapshot.version); - } - }; - return LineIndexSnapshot; - }()); - server.LineIndexSnapshot = LineIndexSnapshot; - var LineIndex = (function () { - function LineIndex() { - this.checkEdits = false; - } - LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { - return this.root.charOffsetToLineNumberAndPos(1, charOffset); - }; - LineIndex.prototype.lineNumberToInfo = function (lineNumber) { - var lineCount = this.root.lineCount(); - if (lineNumber <= lineCount) { - var lineInfo = this.root.lineNumberToInfo(lineNumber, 0); - lineInfo.line = lineNumber; - return lineInfo; - } - else { - return { - line: lineNumber, - offset: this.root.charCount() - }; - } - }; - LineIndex.prototype.load = function (lines) { - if (lines.length > 0) { - var leaves = []; - for (var i = 0; i < lines.length; i++) { - leaves[i] = new LineLeaf(lines[i]); - } - this.root = LineIndex.buildTreeFromBottom(leaves); - } - else { - this.root = new LineNode(); - } - }; - LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { - this.root.walk(rangeStart, rangeLength, walkFns); - }; - LineIndex.prototype.getText = function (rangeStart, rangeLength) { - var accum = ""; - if ((rangeLength > 0) && (rangeStart < this.root.charCount())) { - this.walk(rangeStart, rangeLength, { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - accum = accum.concat(ll.text.substring(relativeStart, relativeStart + relativeLength)); - } - }); - } - return accum; - }; - LineIndex.prototype.getLength = function () { - return this.root.charCount(); - }; - LineIndex.prototype.every = function (f, rangeStart, rangeEnd) { - if (!rangeEnd) { - rangeEnd = this.root.charCount(); - } - var walkFns = { - goSubtree: true, - done: false, - leaf: function (relativeStart, relativeLength, ll) { - if (!f(ll, relativeStart, relativeLength)) { - this.done = true; - } - } - }; - this.walk(rangeStart, rangeEnd - rangeStart, walkFns); - return !walkFns.done; - }; - LineIndex.prototype.edit = function (pos, deleteLength, newText) { - function editFlat(source, s, dl, nt) { - if (nt === void 0) { nt = ""; } - return source.substring(0, s) + nt + source.substring(s + dl, source.length); - } - if (this.root.charCount() === 0) { - if (newText !== undefined) { - this.load(LineIndex.linesFromText(newText).lines); - return this; - } - } - else { - var checkText = void 0; - if (this.checkEdits) { - checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); - } - var walker = new EditWalker(); - if (pos >= this.root.charCount()) { - pos = this.root.charCount() - 1; - var endString = this.getText(pos, 1); - if (newText) { - newText = endString + newText; - } - else { - newText = endString; - } - deleteLength = 0; - walker.suppressTrailingText = true; - } - else if (deleteLength > 0) { - var e = pos + deleteLength; - var lineInfo = this.charOffsetToLineNumberAndPos(e); - if ((lineInfo && (lineInfo.offset === 0))) { - deleteLength += lineInfo.text.length; - if (newText) { - newText = newText + lineInfo.text; - } - else { - newText = lineInfo.text; - } - } - } - if (pos < this.root.charCount()) { - this.root.walk(pos, deleteLength, walker); - walker.insertLines(newText); - } - if (this.checkEdits) { - var updatedText = this.getText(0, this.root.charCount()); - ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); - } - return walker.lineIndex; - } - }; - LineIndex.buildTreeFromBottom = function (nodes) { - var nodeCount = Math.ceil(nodes.length / lineCollectionCapacity); - var interiorNodes = []; - var nodeIndex = 0; - for (var i = 0; i < nodeCount; i++) { - interiorNodes[i] = new LineNode(); - var charCount = 0; - var lineCount = 0; - for (var j = 0; j < lineCollectionCapacity; j++) { - if (nodeIndex < nodes.length) { - interiorNodes[i].add(nodes[nodeIndex]); - charCount += nodes[nodeIndex].charCount(); - lineCount += nodes[nodeIndex].lineCount(); - } - else { - break; - } - nodeIndex++; - } - interiorNodes[i].totalChars = charCount; - interiorNodes[i].totalLines = lineCount; - } - if (interiorNodes.length === 1) { - return interiorNodes[0]; - } - else { - return this.buildTreeFromBottom(interiorNodes); - } - }; - LineIndex.linesFromText = function (text) { - var lineStarts = ts.computeLineStarts(text); - if (lineStarts.length === 0) { - return { lines: [], lineMap: lineStarts }; - } - var lines = new Array(lineStarts.length); - var lc = lineStarts.length - 1; - for (var lmi = 0; lmi < lc; lmi++) { - lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]); - } - var endText = text.substring(lineStarts[lc]); - if (endText.length > 0) { - lines[lc] = endText; - } - else { - lines.length--; - } - return { lines: lines, lineMap: lineStarts }; - }; - return LineIndex; - }()); - server.LineIndex = LineIndex; - var LineNode = (function () { - function LineNode() { - this.totalChars = 0; - this.totalLines = 0; - this.children = []; - } - LineNode.prototype.isLeaf = function () { - return false; - }; - LineNode.prototype.updateCounts = function () { - this.totalChars = 0; - this.totalLines = 0; - for (var _i = 0, _a = this.children; _i < _a.length; _i++) { - var child = _a[_i]; - this.totalChars += child.charCount(); - this.totalLines += child.lineCount(); - } - }; - LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { - if (walkFns.pre) { - walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - if (walkFns.goSubtree) { - this.children[childIndex].walk(rangeStart, rangeLength, walkFns); - if (walkFns.post) { - walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); - } - } - else { - walkFns.goSubtree = true; - } - return walkFns.done; - }; - LineNode.prototype.skipChild = function (relativeStart, relativeLength, childIndex, walkFns, nodeType) { - if (walkFns.pre && (!walkFns.done)) { - walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType); - walkFns.goSubtree = true; - } - }; - LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { - var childIndex = 0; - var child = this.children[0]; - var childCharCount = child.charCount(); - var adjustedStart = rangeStart; - while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, CharRangeSection.PreStart); - adjustedStart -= childCharCount; - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - } - if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { - return; - } - } - else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { - return; - } - var adjustedLength = rangeLength - (childCharCount - adjustedStart); - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, CharRangeSection.Mid)) { - return; - } - adjustedLength -= childCharCount; - childIndex++; - child = this.children[childIndex]; - childCharCount = child.charCount(); - } - if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { - return; - } - } - } - if (walkFns.pre) { - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, CharRangeSection.PostEnd); - } - } - } - }; - LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { - var childInfo = this.childFromCharOffset(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset, - }; - } - else if (childInfo.childIndex < this.children.length) { - if (childInfo.child.isLeaf()) { - return { - line: childInfo.lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); - } - } - else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; - } - }; - LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { - var childInfo = this.childFromLineNumber(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset - }; - } - else if (childInfo.child.isLeaf()) { - return { - line: lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; - } - else { - var lineNode = (childInfo.child); - return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); - } - }; - LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { - var child; - var relativeLineNumber = lineNumber; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - var childLineCount = child.lineCount(); - if (childLineCount >= relativeLineNumber) { - break; - } - else { - relativeLineNumber -= childLineCount; - charOffset += child.charCount(); - } - } - return { - child: child, - childIndex: i, - relativeLineNumber: relativeLineNumber, - charOffset: charOffset - }; - }; - LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { - var child; - var i; - var len; - for (i = 0, len = this.children.length; i < len; i++) { - child = this.children[i]; - if (child.charCount() > charOffset) { - break; - } - else { - charOffset -= child.charCount(); - lineNumber += child.lineCount(); - } - } - return { - child: child, - childIndex: i, - charOffset: charOffset, - lineNumber: lineNumber - }; - }; - LineNode.prototype.splitAfter = function (childIndex) { - var splitNode; - var clen = this.children.length; - childIndex++; - var endLength = childIndex; - if (childIndex < clen) { - splitNode = new LineNode(); - while (childIndex < clen) { - splitNode.add(this.children[childIndex]); - childIndex++; - } - splitNode.updateCounts(); - } - this.children.length = endLength; - return splitNode; - }; - LineNode.prototype.remove = function (child) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - if (childIndex < (clen - 1)) { - for (var i = childIndex; i < (clen - 1); i++) { - this.children[i] = this.children[i + 1]; - } - } - this.children.length--; - }; - LineNode.prototype.findChildIndex = function (child) { - var childIndex = 0; - var clen = this.children.length; - while ((this.children[childIndex] !== child) && (childIndex < clen)) - childIndex++; - return childIndex; - }; - LineNode.prototype.insertAt = function (child, nodes) { - var childIndex = this.findChildIndex(child); - var clen = this.children.length; - var nodeCount = nodes.length; - if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { - this.add(nodes[0]); - this.updateCounts(); - return []; - } - else { - var shiftNode = this.splitAfter(childIndex); - var nodeIndex = 0; - childIndex++; - while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { - this.children[childIndex] = nodes[nodeIndex]; - childIndex++; - nodeIndex++; - } - var splitNodes = []; - var splitNodeCount = 0; - if (nodeIndex < nodeCount) { - splitNodeCount = Math.ceil((nodeCount - nodeIndex) / lineCollectionCapacity); - splitNodes = new Array(splitNodeCount); - var splitNodeIndex = 0; - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i] = new LineNode(); - } - var splitNode = splitNodes[0]; - while (nodeIndex < nodeCount) { - splitNode.add(nodes[nodeIndex]); - nodeIndex++; - if (splitNode.children.length === lineCollectionCapacity) { - splitNodeIndex++; - splitNode = splitNodes[splitNodeIndex]; - } - } - for (var i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length === 0) { - splitNodes.length--; - } - } - } - if (shiftNode) { - splitNodes[splitNodes.length] = shiftNode; - } - this.updateCounts(); - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i].updateCounts(); - } - return splitNodes; - } - }; - LineNode.prototype.add = function (collection) { - this.children[this.children.length] = collection; - return (this.children.length < lineCollectionCapacity); - }; - LineNode.prototype.charCount = function () { - return this.totalChars; - }; - LineNode.prototype.lineCount = function () { - return this.totalLines; - }; - return LineNode; - }()); - server.LineNode = LineNode; - var LineLeaf = (function () { - function LineLeaf(text) { - this.text = text; - } - LineLeaf.prototype.isLeaf = function () { return true; }; - LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { - walkFns.leaf(rangeStart, rangeLength, this); + BuilderFileInfo.prototype.computeHash = function (text) { + return this.project.projectService.host.createHash(text); }; - LineLeaf.prototype.charCount = function () { - return this.text.length; + BuilderFileInfo.prototype.getSourceFile = function () { + return this.project.getSourceFile(this.scriptInfo.path); }; - LineLeaf.prototype.lineCount = function () { - return 1; + BuilderFileInfo.prototype.updateShapeSignature = function () { + var sourceFile = this.getSourceFile(); + if (!sourceFile) { + return true; + } + var lastSignature = this.lastCheckedShapeSignature; + if (sourceFile.isDeclarationFile) { + this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); + } + else { + var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); + if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { + this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); + } + } + return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; }; - return LineLeaf; + return BuilderFileInfo; }()); - server.LineLeaf = LineLeaf; + server.BuilderFileInfo = BuilderFileInfo; + var AbstractBuilder = (function () { + function AbstractBuilder(project, ctor) { + this.project = project; + this.ctor = ctor; + } + AbstractBuilder.prototype.getFileInfos = function () { + return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); + }; + AbstractBuilder.prototype.clear = function () { + this.fileInfos_doNotAccessDirectly = undefined; + }; + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.getFileInfos().get(path); + }; + AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { + var fileInfo = this.getFileInfo(path); + if (!fileInfo) { + var scriptInfo = this.project.getScriptInfo(path); + fileInfo = new this.ctor(scriptInfo, this.project); + this.setFileInfo(path, fileInfo); + } + return fileInfo; + }; + AbstractBuilder.prototype.getFileInfoPaths = function () { + return this.getFileInfos().getKeys(); + }; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.getFileInfos().set(path, info); + }; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.getFileInfos().remove(path); + }; + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); + }; + AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo) { + return false; + } + var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; + if (!emitSkipped) { + var projectRootPath = this.project.getProjectRootPath(); + for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { + var outputFile = outputFiles_1[_i]; + var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); + writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); + } + } + return !emitSkipped; + }; + return AbstractBuilder; + }()); + var NonModuleBuilder = (function (_super) { + __extends(NonModuleBuilder, _super); + function NonModuleBuilder(project) { + var _this = _super.call(this, project, BuilderFileInfo) || this; + _this.project = project; + return _this; + } + NonModuleBuilder.prototype.onProjectUpdateGraph = function () { + }; + NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + var info = this.getOrCreateFileInfo(scriptInfo.path); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + if (info.updateShapeSignature()) { + var options = this.project.getCompilerOptions(); + if (options && (options.out || options.outFile)) { + return singleFileResult; + } + return this.project.getAllEmittableFiles(); + } + return singleFileResult; + }; + return NonModuleBuilder; + }(AbstractBuilder)); + var ModuleBuilderFileInfo = (function (_super) { + __extends(ModuleBuilderFileInfo, _super); + function ModuleBuilderFileInfo() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.references = []; + _this.referencedBy = []; + return _this; + } + ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { + var l = lf.scriptInfo.fileName; + var r = rf.scriptInfo.fileName; + return (l < r ? -1 : (l > r ? 1 : 0)); + }; + ; + ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { + if (array.length === 0) { + array.push(fileInfo); + return; + } + var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, fileInfo); + } + }; + ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { + if (!array || array.length === 0) { + return; + } + if (array[0] === fileInfo) { + array.splice(0, 1); + return; + } + var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (removeIndex >= 0) { + array.splice(removeIndex, 1); + } + }; + ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeFileReferences = function () { + for (var _i = 0, _a = this.references; _i < _a.length; _i++) { + var reference = _a[_i]; + reference.removeReferencedBy(this); + } + this.references = []; + }; + return ModuleBuilderFileInfo; + }(BuilderFileInfo)); + var ModuleBuilder = (function (_super) { + __extends(ModuleBuilder, _super); + function ModuleBuilder(project) { + var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; + _this.project = project; + return _this; + } + ModuleBuilder.prototype.clear = function () { + this.projectVersionForDependencyGraph = undefined; + _super.prototype.clear.call(this); + }; + ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { + var _this = this; + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return []; + } + var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); + if (referencedFilePaths.length > 0) { + return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); + } + return []; + }; + ModuleBuilder.prototype.onProjectUpdateGraph = function () { + this.ensureProjectDependencyGraphUpToDate(); + }; + ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { + var _this = this; + if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { + var currentScriptInfos = this.project.getScriptInfos(); + for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { + var scriptInfo = currentScriptInfos_1[_i]; + var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); + this.updateFileReferences(fileInfo); + } + this.forEachFileInfo(function (fileInfo) { + if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { + fileInfo.removeFileReferences(); + _this.removeFileInfo(fileInfo.scriptInfo.path); + } + }); + this.projectVersionForDependencyGraph = this.project.getProjectVersion(); + } + }; + ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { + if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { + return; + } + var newReferences = this.getReferencedFileInfos(fileInfo); + var oldReferences = fileInfo.references; + var oldIndex = 0; + var newIndex = 0; + while (oldIndex < oldReferences.length && newIndex < newReferences.length) { + var oldReference = oldReferences[oldIndex]; + var newReference = newReferences[newIndex]; + var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); + if (compare < 0) { + oldReference.removeReferencedBy(fileInfo); + oldIndex++; + } + else if (compare > 0) { + newReference.addReferencedBy(fileInfo); + newIndex++; + } + else { + oldIndex++; + newIndex++; + } + } + for (var i = oldIndex; i < oldReferences.length; i++) { + oldReferences[i].removeReferencedBy(fileInfo); + } + for (var i = newIndex; i < newReferences.length; i++) { + newReferences[i].addReferencedBy(fileInfo); + } + fileInfo.references = newReferences; + fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); + }; + ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + this.ensureProjectDependencyGraphUpToDate(); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo || !fileInfo.updateShapeSignature()) { + return singleFileResult; + } + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return this.project.getAllEmittableFiles(); + } + var options = this.project.getCompilerOptions(); + if (options && (options.isolatedModules || options.out || options.outFile)) { + return singleFileResult; + } + var queue = fileInfo.referencedBy.slice(0); + var fileNameSet = ts.createMap(); + fileNameSet[scriptInfo.fileName] = scriptInfo; + while (queue.length > 0) { + var processingFileInfo = queue.pop(); + if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { + for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { + var potentialFileInfo = _a[_i]; + if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { + queue.push(potentialFileInfo); + } + } + } + fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; + } + var result = []; + for (var fileName in fileNameSet) { + if (shouldEmitFile(fileNameSet[fileName])) { + result.push(fileName); + } + } + return result; + }; + return ModuleBuilder; + }(AbstractBuilder)); + function createBuilder(project) { + var moduleKind = project.getCompilerOptions().module; + switch (moduleKind) { + case ts.ModuleKind.None: + return new NonModuleBuilder(project); + default: + return new ModuleBuilder(project); + } + } + server.createBuilder = createBuilder; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var debugObjectHost = (function () { return this; })(); From 9221336bf1bd8e1c53ec5f3cef12c829aa4c1328 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 6 Jan 2017 13:13:45 -0800 Subject: [PATCH 059/175] Fix name: `mapEntries` is more accurate --- src/compiler/core.ts | 2 +- src/harness/unittests/configurationExtension.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 3b2197d6efa..b65634565b7 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -506,7 +506,7 @@ namespace ts { return result; } - export function mapValues(map: Map, f: (key: string, value: T) => [string, U]): Map { + export function mapEntries(map: Map, f: (key: string, value: T) => [string, U]): Map { if (!map) { return undefined; } diff --git a/src/harness/unittests/configurationExtension.ts b/src/harness/unittests/configurationExtension.ts index 03eb825811b..c68d07f5123 100644 --- a/src/harness/unittests/configurationExtension.ts +++ b/src/harness/unittests/configurationExtension.ts @@ -89,7 +89,7 @@ namespace ts { }); const caseInsensitiveBasePath = "c:/dev/"; - const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, mapValues(testContents, (key, content) => [`c:${key}`, content])); + const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, mapEntries(testContents, (key, content) => [`c:${key}`, content])); const caseSensitiveBasePath = "/dev/"; const caseSensitiveHost = new Utils.MockParseConfigHost(caseSensitiveBasePath, /*useCaseSensitiveFileNames*/ true, testContents); From 06aa905d2068c77f8e2e9f798ddae4b0174ff115 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 6 Jan 2017 16:47:33 -0800 Subject: [PATCH 060/175] Improve detection and handling of circular generic constraints --- src/compiler/checker.ts | 174 +++++++++++++++++++++++----------------- 1 file changed, 100 insertions(+), 74 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 33b3505661a..3769f2493b3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -164,6 +164,7 @@ namespace ts { anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType; const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -4135,9 +4136,6 @@ namespace ts { if (!links.declaredType) { const type = createType(TypeFlags.TypeParameter); type.symbol = symbol; - if (!(getDeclarationOfKind(symbol, SyntaxKind.TypeParameter)).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -4754,19 +4752,79 @@ namespace ts { getPropertiesOfObjectType(type); } + function getConstraintOfTypeVariable(type: TypeVariable): Type { + return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : getBaseConstraintOfTypeVariable(type); + } + + function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + + function getBaseConstraintOfTypeVariable(type: TypeVariable): Type { + const constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + + function hasNonCircularBaseConstraint(type: TypeVariable): boolean { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + /** - * The apparent type of a type parameter is the base constraint instantiated with the type parameter - * as the type argument for the 'this' type. + * Return the resolved base constraint of a type variable. The noConstraintType singleton is returned if the + * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint + * circularly references the type variable. */ - function getApparentTypeOfTypeVariable(type: TypeVariable) { + function getResolvedBaseConstraint(type: TypeVariable): Type { + let typeStack: Type[]; + let circular: boolean; if (!type.resolvedApparentType) { - let constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & TypeFlags.TypeParameter) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + typeStack = []; + const constraint = getBaseConstraint(type); + type.resolvedApparentType = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } return type.resolvedApparentType; + + function getBaseConstraint(t: Type): Type { + if (contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + const result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + + function computeBaseConstraint(t: Type): Type { + if (t.flags & TypeFlags.TypeParameter) { + const constraint = getConstraintFromTypeParameter(t); + return (t).isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & TypeFlags.UnionOrIntersection) { + const types = (t).types; + const baseTypes: Type[] = []; + for (const type of types) { + const baseType = getBaseConstraint(type); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & TypeFlags.Union && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & TypeFlags.Intersection && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & TypeFlags.Index) { + return stringType; + } + if (t.flags & TypeFlags.IndexedAccess) { + const baseObjectType = getBaseConstraint((t).objectType); + const baseIndexType = getBaseConstraint((t).indexType); + const baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } } /** @@ -4775,7 +4833,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 ? getApparentTypeOfTypeVariable(type) : type; + const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfTypeVariable(type) || emptyObjectType : type; return t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : @@ -5329,20 +5387,7 @@ namespace ts { return (getDeclarationOfKind(type.symbol, SyntaxKind.TypeParameter)).constraint; } - function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean { - let checked: Type[]; - while (type && type.flags & TypeFlags.TypeParameter && !((type as TypeParameter).isThisType) && !contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - const constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - - function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type { + function getConstraintFromTypeParameter(typeParameter: TypeParameter): Type { if (!typeParameter.constraint) { if (typeParameter.target) { const targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -5350,23 +5395,12 @@ namespace ts { } else { const constraintDeclaration = getConstraintDeclaration(typeParameter); - let constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type: TypeVariable): Type { - return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : - type.flags & TypeFlags.IndexedAccess ? (type).constraint : - undefined; - } - function getParentSymbolOfTypeParameter(typeParameter: TypeParameter): Symbol { return getSymbolOfNode(getDeclarationOfKind(typeParameter.symbol, SyntaxKind.TypeParameter).parent); } @@ -6042,24 +6076,6 @@ namespace ts { const type = createType(TypeFlags.IndexedAccess); type.objectType = objectType; type.indexType = indexType; - // We eagerly compute the constraint of the indexed access type such that circularity - // errors are immediately caught and reported. For example, class C { x: this["x"] } - // becomes an error only when the constraint is eagerly computed. - if (type.objectType.flags & TypeFlags.StructuredType) { - // The constraint of T[K], where T is an object, union, or intersection type, - // is the type of the string index signature of T, if any. - type.constraint = getIndexTypeOfType(type.objectType, IndexKind.String); - } - else if (type.objectType.flags & TypeFlags.TypeVariable) { - // The constraint of T[K], where T is a type variable, is A[K], where A is the - // apparent type of T. - const apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind((type).indexType, TypeFlags.StringLike) ? - getIndexedAccessType(apparentType, (type).indexType) : - getIndexTypeOfType(apparentType, IndexKind.String); - } - } return type; } @@ -6150,13 +6166,6 @@ namespace ts { if (objectType.flags & TypeFlags.Any) { return objectType; } - // We first check that the index type is assignable to 'keyof T' for the object type. - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the // type Box. @@ -7436,8 +7445,9 @@ 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. - if ((target).constraint) { - if (result = isRelatedTo(source, (target).constraint, reportErrors)) { + const constraint = getBaseConstraintOfTypeVariable(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -7475,8 +7485,9 @@ 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. - if ((source).constraint) { - if (result = isRelatedTo((source).constraint, target, reportErrors)) { + const constraint = getBaseConstraintOfTypeVariable(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -12528,7 +12539,7 @@ namespace ts { return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression: Expression, expressionType: Type, reportError: boolean): boolean { @@ -15186,14 +15197,14 @@ namespace ts { function isLiteralContextualType(contextualType: Type) { if (contextualType) { if (contextualType.flags & TypeFlags.TypeVariable) { - const apparentType = getApparentTypeOfTypeVariable(contextualType); + const constraint = getBaseConstraintOfTypeVariable(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. - if (apparentType.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { + if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (TypeFlags.Literal | TypeFlags.Index)); } @@ -15391,6 +15402,10 @@ namespace ts { } checkSourceElement(node.constraint); + const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0); @@ -16014,8 +16029,20 @@ namespace ts { forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode) { + if (type.flags & TypeFlags.IndexedAccess) { + // Check that the index type is assignable to 'keyof T' for the object type. + const objectType = (type).objectType; + const indexType = (type).indexType; + if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { + error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + } + } + return type; + } + function checkIndexedAccessType(node: IndexedAccessTypeNode) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node: MappedTypeNode) { @@ -16023,8 +16050,7 @@ namespace ts { checkSourceElement(node.type); const type = getTypeFromMappedTypeNode(node); const constraintType = getConstraintTypeFromMappedType(type); - const keyType = constraintType.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node: Node): boolean { From ee03c0dc870c1afc7f0e4c0b9efc98bef1ea837d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 6 Jan 2017 17:19:34 -0800 Subject: [PATCH 061/175] Update tests --- .../compiler/typeParameterWithInvalidConstraintType.ts | 1 - .../types/keyof/circularIndexedAccessErrors.ts | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/cases/compiler/typeParameterWithInvalidConstraintType.ts b/tests/cases/compiler/typeParameterWithInvalidConstraintType.ts index 7c92ad4575a..a97876b0ab3 100644 --- a/tests/cases/compiler/typeParameterWithInvalidConstraintType.ts +++ b/tests/cases/compiler/typeParameterWithInvalidConstraintType.ts @@ -1,7 +1,6 @@ class A { foo() { var x: T; - // no error expected below this line var a = x.foo(); var b = new x(123); var c = x[1]; diff --git a/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts b/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts index c01030c7fa9..2243ee8aaad 100644 --- a/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts +++ b/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts @@ -13,7 +13,7 @@ declare let x2: T2<"x">; let x2x = x2.x; interface T3> { - x: T["x"]; // Error + x: T["x"]; } interface T4> { @@ -25,7 +25,7 @@ class C1 { } class C2 { - x: this["y"]; // Error - y: this["z"]; // Error - z: this["x"]; // Error + x: this["y"]; + y: this["z"]; + z: this["x"]; } \ No newline at end of file From 33e568465a30a1f75bf0910dfc8f1da1140df914 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 6 Jan 2017 17:20:28 -0800 Subject: [PATCH 062/175] Accept new baselines --- .../circularIndexedAccessErrors.errors.txt | 22 +++++-------------- .../reference/circularIndexedAccessErrors.js | 8 +++---- .../reference/mappedTypeErrors.errors.txt | 4 ++-- .../mappedTypeRelationships.errors.txt | 12 +++++++++- ...erIndirectlyConstrainedToItself.errors.txt | 5 ++++- ...ameterWithInvalidConstraintType.errors.txt | 12 ++++++++-- .../typeParameterWithInvalidConstraintType.js | 2 -- 7 files changed, 36 insertions(+), 29 deletions(-) diff --git a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt index e3076e08b7e..e5eaa08d054 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt @@ -1,14 +1,10 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(3,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(7,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(15,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(19,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(27,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(28,5): error TS2502: 'y' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error TS2502: 'z' is referenced directly or indirectly in its own type annotation. -==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (8 errors) ==== +==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (4 errors) ==== type T1 = { x: T1["x"]; // Error @@ -27,9 +23,7 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error let x2x = x2.x; interface T3> { - x: T["x"]; // Error - ~~~~~~~~~~ -!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation. + x: T["x"]; } interface T4> { @@ -45,13 +39,7 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error } class C2 { - x: this["y"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation. - y: this["z"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'y' is referenced directly or indirectly in its own type annotation. - z: this["x"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'z' is referenced directly or indirectly in its own type annotation. + x: this["y"]; + y: this["z"]; + z: this["x"]; } \ No newline at end of file diff --git a/tests/baselines/reference/circularIndexedAccessErrors.js b/tests/baselines/reference/circularIndexedAccessErrors.js index 46784ae8d18..2e4ae3bd841 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.js +++ b/tests/baselines/reference/circularIndexedAccessErrors.js @@ -13,7 +13,7 @@ declare let x2: T2<"x">; let x2x = x2.x; interface T3> { - x: T["x"]; // Error + x: T["x"]; } interface T4> { @@ -25,9 +25,9 @@ class C1 { } class C2 { - x: this["y"]; // Error - y: this["z"]; // Error - z: this["x"]; // Error + x: this["y"]; + y: this["z"]; + z: this["x"]; } //// [circularIndexedAccessErrors.js] diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index 94644a96af9..c7571295521 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -45,7 +45,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,5): error TS2322: T tests/cases/conformance/types/mapped/mappedTypeErrors.ts(131,5): error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'. Types of property 'a' are incompatible. Type 'string' is not assignable to type 'number | undefined'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,16): error TS2322: Type '{}' is not assignable to type 'string'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,16): error TS2322: Type 'T' is not assignable to type 'string'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,21): error TS2536: Type 'P' cannot be used to index type 'T'. @@ -259,7 +259,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,21): error TS2536: pf: {[P in F]?: T[P]}, pt: {[P in T]?: T[P]}, // note: should be in keyof T ~ -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type 'T' is not assignable to type 'string'. ~~~~ !!! error TS2536: Type 'P' cannot be used to index type 'T'. }; diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index e8e0371ed9a..ce6ecaa61fa 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -3,8 +3,12 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(12,5): error TS2 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'. 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'. 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'. 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]'. @@ -28,7 +32,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(71,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2322: Type 'Partial' is not assignable to type 'T'. -==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (18 errors) ==== +==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (20 errors) ==== function f1(x: T, k: keyof T) { return x[k]; @@ -59,6 +63,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. 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 TS2536: Type 'keyof U' cannot be used to index type 'T'. } @@ -68,6 +75,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. 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 TS2536: Type 'K' cannot be used to index type 'T'. } diff --git a/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt b/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt index 4cfa9da2133..ac7b58bb846 100644 --- a/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt +++ b/tests/baselines/reference/typeParameterIndirectlyConstrainedToItself.errors.txt @@ -23,11 +23,12 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterInd tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,21): error TS2313: Type parameter 'T' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,34): error TS2313: Type parameter 'U' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(16,47): error TS2313: Type parameter 'V' has a circular constraint. +tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,19): error TS2313: Type parameter 'U' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,32): error TS2313: Type parameter 'T' has a circular constraint. tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts(18,45): error TS2313: Type parameter 'V' has a circular constraint. -==== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts (27 errors) ==== +==== tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterIndirectlyConstrainedToItself.ts (28 errors) ==== class C { } ~ !!! error TS2313: Type parameter 'U' has a circular constraint. @@ -96,6 +97,8 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterInd !!! error TS2313: Type parameter 'V' has a circular constraint. class D { } + ~ +!!! error TS2313: Type parameter 'U' has a circular constraint. ~ !!! error TS2313: Type parameter 'T' has a circular constraint. ~ diff --git a/tests/baselines/reference/typeParameterWithInvalidConstraintType.errors.txt b/tests/baselines/reference/typeParameterWithInvalidConstraintType.errors.txt index 79af423f917..e9dfb5ba3cd 100644 --- a/tests/baselines/reference/typeParameterWithInvalidConstraintType.errors.txt +++ b/tests/baselines/reference/typeParameterWithInvalidConstraintType.errors.txt @@ -1,16 +1,24 @@ tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(1,19): error TS2313: Type parameter 'T' has a circular constraint. +tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(4,19): error TS2339: Property 'foo' does not exist on type 'T'. +tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(5,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +tests/cases/compiler/typeParameterWithInvalidConstraintType.ts(7,17): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. -==== tests/cases/compiler/typeParameterWithInvalidConstraintType.ts (1 errors) ==== +==== tests/cases/compiler/typeParameterWithInvalidConstraintType.ts (4 errors) ==== class A { ~ !!! error TS2313: Type parameter 'T' has a circular constraint. foo() { var x: T; - // no error expected below this line var a = x.foo(); + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'T'. var b = new x(123); + ~~~~~~~~~~ +!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. var c = x[1]; var d = x(); + ~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterWithInvalidConstraintType.js b/tests/baselines/reference/typeParameterWithInvalidConstraintType.js index a40056f6a59..40a2aeacf4b 100644 --- a/tests/baselines/reference/typeParameterWithInvalidConstraintType.js +++ b/tests/baselines/reference/typeParameterWithInvalidConstraintType.js @@ -2,7 +2,6 @@ class A { foo() { var x: T; - // no error expected below this line var a = x.foo(); var b = new x(123); var c = x[1]; @@ -16,7 +15,6 @@ var A = (function () { } A.prototype.foo = function () { var x; - // no error expected below this line var a = x.foo(); var b = new x(123); var c = x[1]; From f1da780a5e68ba7f863cf13f25e1c63d37846bb9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 6 Jan 2017 17:20:58 -0800 Subject: [PATCH 063/175] Add regression tests --- .../reference/keyofAndIndexedAccess.js | 68 +- .../reference/keyofAndIndexedAccess.symbols | 623 +++++++++++------- .../reference/keyofAndIndexedAccess.types | 138 ++++ .../types/keyof/keyofAndIndexedAccess.ts | 35 +- 4 files changed, 612 insertions(+), 252 deletions(-) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.js b/tests/baselines/reference/keyofAndIndexedAccess.js index 4b93897fdc4..3ad7bdd79f8 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.js +++ b/tests/baselines/reference/keyofAndIndexedAccess.js @@ -296,6 +296,30 @@ class C1 { } } +type S2 = { + a: string; + b: string; +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { + x1 = x2; + x1 = x3; + x1 = x4; + x2 = x1; + x2 = x3; + x2 = x4; + x3 = x1; + x3 = x2; + x3 = x4; + x4 = x1; + x4 = x2; + x4 = x3; + x1.length; + x2.length; + x3.length; + x4.length; +} + // Repros from #12011 class Base { @@ -429,7 +453,17 @@ type SomeMethodDescriptor = { returnValue: string[]; } -let result = dispatchMethod("someMethod", ["hello", 35]); +let result = dispatchMethod("someMethod", ["hello", 35]); + +// Repro from #13073 + +type KeyTypes = "a" | "b" +let MyThingy: { [key in KeyTypes]: string[] }; + +function addToMyThingy(key: S) { + MyThingy[key].push("a"); +} + //// [keyofAndIndexedAccess.js] var __extends = (this && this.__extends) || function (d, b) { @@ -644,6 +678,24 @@ var C1 = (function () { }; return C1; }()); +function f90(x1, x2, x3, x4) { + x1 = x2; + x1 = x3; + x1 = x4; + x2 = x1; + x2 = x3; + x2 = x4; + x3 = x1; + x3 = x2; + x3 = x4; + x4 = x1; + x4 = x2; + x4 = x3; + x1.length; + x2.length; + x3.length; + x4.length; +} // Repros from #12011 var Base = (function () { function Base() { @@ -713,6 +765,10 @@ function f(p) { a[p].add; // any } var result = dispatchMethod("someMethod", ["hello", 35]); +var MyThingy; +function addToMyThingy(key) { + MyThingy[key].push("a"); +} //// [keyofAndIndexedAccess.d.ts] @@ -848,6 +904,11 @@ declare class C1 { set(key: K, value: this[K]): void; foo(): void; } +declare type S2 = { + a: string; + b: string; +}; +declare function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]): void; declare class Base { get(prop: K): this[K]; set(prop: K, value: this[K]): void; @@ -920,3 +981,8 @@ declare type SomeMethodDescriptor = { returnValue: string[]; }; declare let result: string[]; +declare type KeyTypes = "a" | "b"; +declare let MyThingy: { + [key in KeyTypes]: string[]; +}; +declare function addToMyThingy(key: S): void; diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index 1c69d4959d8..fb8129a5301 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -1139,440 +1139,563 @@ class C1 { } } +type S2 = { +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) + + a: string; +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 297, 11)) + + b: string; +>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 298, 14)) + +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { +>f90 : Symbol(f90, Decl(keyofAndIndexedAccess.ts, 300, 2)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) + + x1 = x2; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x1 = x3; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x1 = x4; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x2 = x1; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x2 = x3; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x2 = x4; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x3 = x1; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x3 = x2; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x3 = x4; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x4 = x1; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x4 = x2; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x4 = x3; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x1.length; +>x1.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x2.length; +>x2.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x3.length; +>x3.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x4.length; +>x4.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +} + // Repros from #12011 class Base { ->Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) get(prop: K) { ->get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8)) +>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 324, 8)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 324, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 324, 8)) return this[prop]; ->this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30)) +>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 324, 30)) } set(prop: K, value: this[K]) { ->set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) +>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 327, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 327, 38)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) this[prop] = value; ->this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38)) +>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 327, 30)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 327, 38)) } } class Person extends Base { ->Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) parts: number; ->parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 308, 27)) +>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 332, 27)) constructor(parts: number) { ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 334, 16)) super(); ->super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) this.set("parts", parts); ->this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16)) +>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 334, 16)) } getParts() { ->getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 313, 5)) +>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 337, 5)) return this.get("parts") ->this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) ->this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) +>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) +>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) } } class OtherPerson { ->OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) +>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) parts: number; ->parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 319, 19)) +>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 343, 19)) constructor(parts: number) { ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 345, 16)) setProperty(this, "parts", parts); >setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 81, 1)) ->this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16)) +>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 345, 16)) } getParts() { ->getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 323, 5)) +>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 347, 5)) return getProperty(this, "parts") >getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 77, 26)) ->this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) +>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) } } // Modified repro from #12544 function path(obj: T, key1: K1): T[K1]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 331, 37)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 331, 44)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 355, 37)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 355, 44)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) function path(obj: T, key1: K1, key2: K2): T[K1][K2]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 332, 61)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 332, 68)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 332, 78)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 356, 61)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 356, 68)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 356, 78)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) function path(obj: T, key1: K1, key2: K2, key3: K3): T[K1][K2][K3]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 333, 89)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 333, 96)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 333, 106)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 333, 116)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 357, 89)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 357, 96)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 357, 106)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 357, 116)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) function path(obj: any, ...keys: (string | number)[]): any; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 334, 14)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 334, 23)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 358, 14)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 358, 23)) function path(obj: any, ...keys: (string | number)[]): any { ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 359, 14)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 359, 23)) let result = obj; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 359, 14)) for (let k of keys) { ->k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23)) +>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 361, 12)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 359, 23)) result = result[k]; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 361, 12)) } return result; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) } type Thing = { ->Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 365, 1)) a: { x: number, y: string }, ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 343, 14)) ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 344, 8)) ->y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 344, 19)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 367, 14)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 368, 8)) +>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 368, 19)) b: boolean ->b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 344, 32)) +>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 368, 32)) }; function f1(thing: Thing) { ->f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 346, 2)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) ->Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 370, 2)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) +>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 365, 1)) let x1 = path(thing, 'a'); // { x: number, y: string } ->x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 350, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 374, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x2 = path(thing, 'a', 'y'); // string ->x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 351, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 375, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x3 = path(thing, 'b'); // boolean ->x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 352, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 376, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x4 = path(thing, ...['a', 'x']); // any ->x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 353, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 377, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) } // Repro from comment in #12114 const assignTo2 = (object: T, key1: K1, key2: K2) => ->assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 358, 5)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) +>assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 382, 5)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 382, 66)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 382, 76)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 382, 86)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) (value: T[K1][K2]) => object[key1][key2] = value; ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) ->object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 383, 5)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) +>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 382, 66)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 382, 76)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 382, 86)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 383, 5)) // Modified repro from #12573 declare function one(handler: (t: T) => void): T ->one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) ->handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 363, 24)) ->t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 363, 34)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) +>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 383, 53)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 387, 24)) +>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 387, 34)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) var empty = one(() => {}) // inferred as {}, expected ->empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 364, 3)) ->one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53)) +>empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 388, 3)) +>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 383, 53)) type Handlers = { [K in keyof T]: (t: T[K]) => void } ->Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 366, 38)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22)) +>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 388, 25)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 390, 22)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 390, 38)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 390, 22)) declare function on(handlerHash: Handlers): T ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) ->handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 367, 23)) ->Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) +>handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 391, 23)) +>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 388, 25)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) var hashOfEmpty1 = on({ test: () => {} }); // {} ->hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 368, 3)) ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 368, 23)) +>hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 392, 3)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 392, 23)) var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean } ->hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 369, 3)) ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 369, 23)) ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 369, 31)) +>hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 393, 3)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 393, 23)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 393, 31)) // Repro from #12624 interface Options1 { ->Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24)) +>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 393, 52)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 397, 19)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 397, 24)) data?: Data ->data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 373, 36)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19)) +>data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 397, 36)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 397, 19)) computed?: Computed; ->computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 374, 15)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24)) +>computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 398, 15)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 397, 24)) } declare class Component1 { ->Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) +>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 400, 1)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) constructor(options: Options1); ->options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 379, 16)) ->Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) +>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 403, 16)) +>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 393, 52)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) get(key: K): (Data & Computed)[K]; ->get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) ->key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 380, 43)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) +>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 404, 43)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) } let c1 = new Component1({ ->c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3)) ->Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1)) +>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 407, 3)) +>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 400, 1)) data: { ->data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 383, 25)) +>data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 407, 25)) hello: "" ->hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 384, 11)) +>hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 408, 11)) } }); c1.get("hello"); ->c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) ->c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3)) ->get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) +>c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) +>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 407, 3)) +>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) // Repro from #12625 interface Options2 { ->Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24)) +>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 413, 16)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 417, 19)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 417, 24)) data?: Data ->data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 393, 36)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19)) +>data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 417, 36)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 417, 19)) computed?: Computed; ->computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 394, 15)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24)) +>computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 418, 15)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 417, 24)) } declare class Component2 { ->Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 396, 1)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) +>Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 420, 1)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) constructor(options: Options2); ->options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 399, 16)) ->Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) +>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 423, 16)) +>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 413, 16)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) get(key: K): (Data & Computed)[K]; ->get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 399, 51)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) ->key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 400, 47)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) +>get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 423, 51)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 424, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) } // Repro from #12641 interface R { ->R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1)) +>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 425, 1)) p: number; ->p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 405, 13)) +>p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 429, 13)) } function f(p: K) { ->f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 407, 1)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11)) ->R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1)) ->p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11)) +>f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 431, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 433, 11)) +>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 425, 1)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 433, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 433, 11)) let a: any; ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 434, 7)) a[p].add; // any ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7)) ->p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 434, 7)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 433, 30)) } // Repro from #12651 type MethodDescriptor = { ->MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1)) +>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 436, 1)) name: string; ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 416, 25)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 440, 25)) args: any[]; ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 417, 14)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 441, 14)) returnValue: any; ->returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 418, 13)) +>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 442, 13)) } declare function dispatchMethod(name: M['name'], args: M['args']): M['returnValue']; ->dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1)) ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 422, 60)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 422, 76)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) +>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 444, 1)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 436, 1)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 446, 60)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 446, 76)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) type SomeMethodDescriptor = { ->SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112)) +>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 446, 112)) name: "someMethod"; ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 424, 29)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 448, 29)) args: [string, number]; ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 425, 20)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 449, 20)) returnValue: string[]; ->returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 426, 24)) +>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 450, 24)) } let result = dispatchMethod("someMethod", ["hello", 35]); ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 430, 3)) ->dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1)) ->SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 454, 3)) +>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 444, 1)) +>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 446, 112)) + +// Repro from #13073 + +type KeyTypes = "a" | "b" +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) + +let MyThingy: { [key in KeyTypes]: string[] }; +>MyThingy : Symbol(MyThingy, Decl(keyofAndIndexedAccess.ts, 459, 3)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 459, 17)) +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) + +function addToMyThingy(key: S) { +>addToMyThingy : Symbol(addToMyThingy, Decl(keyofAndIndexedAccess.ts, 459, 46)) +>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 461, 23)) +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 461, 43)) +>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 461, 23)) + + MyThingy[key].push("a"); +>MyThingy[key].push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>MyThingy : Symbol(MyThingy, Decl(keyofAndIndexedAccess.ts, 459, 3)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 461, 43)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +} diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index f94249806f6..ccf0bde4e1c 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -1385,6 +1385,117 @@ class C1 { } } +type S2 = { +>S2 : S2 + + a: string; +>a : string + + b: string; +>b : string + +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { +>f90 : (x1: string, x2: T["a" | "b"], x3: S2[K], x4: T[K]) => void +>T : T +>S2 : S2 +>K : K +>S2 : S2 +>x1 : string +>S2 : S2 +>S2 : S2 +>x2 : T["a" | "b"] +>T : T +>S2 : S2 +>x3 : S2[K] +>S2 : S2 +>K : K +>x4 : T[K] +>T : T +>K : K + + x1 = x2; +>x1 = x2 : T["a" | "b"] +>x1 : string +>x2 : T["a" | "b"] + + x1 = x3; +>x1 = x3 : S2[K] +>x1 : string +>x3 : S2[K] + + x1 = x4; +>x1 = x4 : T[K] +>x1 : string +>x4 : T[K] + + x2 = x1; +>x2 = x1 : string +>x2 : T["a" | "b"] +>x1 : string + + x2 = x3; +>x2 = x3 : S2[K] +>x2 : T["a" | "b"] +>x3 : S2[K] + + x2 = x4; +>x2 = x4 : T[K] +>x2 : T["a" | "b"] +>x4 : T[K] + + x3 = x1; +>x3 = x1 : string +>x3 : S2[K] +>x1 : string + + x3 = x2; +>x3 = x2 : T["a" | "b"] +>x3 : S2[K] +>x2 : T["a" | "b"] + + x3 = x4; +>x3 = x4 : T[K] +>x3 : S2[K] +>x4 : T[K] + + x4 = x1; +>x4 = x1 : string +>x4 : T[K] +>x1 : string + + x4 = x2; +>x4 = x2 : T["a" | "b"] +>x4 : T[K] +>x2 : T["a" | "b"] + + x4 = x3; +>x4 = x3 : S2[K] +>x4 : T[K] +>x3 : S2[K] + + x1.length; +>x1.length : number +>x1 : string +>length : number + + x2.length; +>x2.length : number +>x2 : T["a" | "b"] +>length : number + + x3.length; +>x3.length : number +>x3 : S2[K] +>length : number + + x4.length; +>x4.length : number +>x4 : T[K] +>length : number +} + // Repros from #12011 class Base { @@ -1875,3 +1986,30 @@ let result = dispatchMethod("someMethod", ["hello", 35]); >"hello" : "hello" >35 : 35 +// Repro from #13073 + +type KeyTypes = "a" | "b" +>KeyTypes : "a" | "b" + +let MyThingy: { [key in KeyTypes]: string[] }; +>MyThingy : { a: string[]; b: string[]; } +>key : key +>KeyTypes : "a" | "b" + +function addToMyThingy(key: S) { +>addToMyThingy : (key: S) => void +>S : S +>KeyTypes : "a" | "b" +>key : S +>S : S + + MyThingy[key].push("a"); +>MyThingy[key].push("a") : number +>MyThingy[key].push : (...items: string[]) => number +>MyThingy[key] : { a: string[]; b: string[]; }[S] +>MyThingy : { a: string[]; b: string[]; } +>key : S +>push : (...items: string[]) => number +>"a" : "a" +} + diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts index ea6a3c2358a..0ef73c736f4 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts @@ -297,6 +297,30 @@ class C1 { } } +type S2 = { + a: string; + b: string; +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { + x1 = x2; + x1 = x3; + x1 = x4; + x2 = x1; + x2 = x3; + x2 = x4; + x3 = x1; + x3 = x2; + x3 = x4; + x4 = x1; + x4 = x2; + x4 = x3; + x1.length; + x2.length; + x3.length; + x4.length; +} + // Repros from #12011 class Base { @@ -430,4 +454,13 @@ type SomeMethodDescriptor = { returnValue: string[]; } -let result = dispatchMethod("someMethod", ["hello", 35]); \ No newline at end of file +let result = dispatchMethod("someMethod", ["hello", 35]); + +// Repro from #13073 + +type KeyTypes = "a" | "b" +let MyThingy: { [key in KeyTypes]: string[] }; + +function addToMyThingy(key: S) { + MyThingy[key].push("a"); +} From 855488fc6d5b9311b463da64f1d32d00ea58cce2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 6 Jan 2017 17:35:09 -0800 Subject: [PATCH 064/175] Add additional regression test --- .../circularIndexedAccessErrors.errors.txt | 20 +++++++++++++++++-- .../reference/circularIndexedAccessErrors.js | 18 ++++++++++++++++- .../keyof/circularIndexedAccessErrors.ts | 11 +++++++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt index e5eaa08d054..f76cfca073e 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt @@ -2,9 +2,11 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(3,5): error T tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(7,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(19,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,24): error TS2313: Type parameter 'T' has a circular constraint. +tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,30): error TS2536: Type '"hello"' cannot be used to index type 'T'. -==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (4 errors) ==== +==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (6 errors) ==== type T1 = { x: T1["x"]; // Error @@ -42,4 +44,18 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error x: this["y"]; y: this["z"]; z: this["x"]; - } \ No newline at end of file + } + + // Repro from #12627 + + interface Foo { + hello: boolean; + } + + function foo() { + ~~~~~~~~~~~~~~~~ +!!! error TS2313: Type parameter 'T' has a circular constraint. + ~~~~~~~~~~ +!!! error TS2536: Type '"hello"' cannot be used to index type 'T'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/circularIndexedAccessErrors.js b/tests/baselines/reference/circularIndexedAccessErrors.js index 2e4ae3bd841..97d059bce19 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.js +++ b/tests/baselines/reference/circularIndexedAccessErrors.js @@ -28,7 +28,17 @@ class C2 { x: this["y"]; y: this["z"]; z: this["x"]; -} +} + +// Repro from #12627 + +interface Foo { + hello: boolean; +} + +function foo() { +} + //// [circularIndexedAccessErrors.js] var x2x = x2.x; @@ -42,6 +52,8 @@ var C2 = (function () { } return C2; }()); +function foo() { +} //// [circularIndexedAccessErrors.d.ts] @@ -68,3 +80,7 @@ declare class C2 { y: this["z"]; z: this["x"]; } +interface Foo { + hello: boolean; +} +declare function foo(): void; diff --git a/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts b/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts index 2243ee8aaad..a53fc6fbf72 100644 --- a/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts +++ b/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts @@ -28,4 +28,13 @@ class C2 { x: this["y"]; y: this["z"]; z: this["x"]; -} \ No newline at end of file +} + +// Repro from #12627 + +interface Foo { + hello: boolean; +} + +function foo() { +} From 54e9ae32e6cee6cb619c07adc4c25d949e1439ac Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Fri, 6 Jan 2017 23:44:17 -0800 Subject: [PATCH 065/175] Fix --project help --- src/compiler/commandLineParser.ts | 6 +++--- src/compiler/diagnosticMessages.json | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 2e2c5c0bdb6..9111a72eb2d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -212,8 +212,8 @@ namespace ts { shortName: "p", type: "string", isFilePath: true, - description: Diagnostics.Compile_the_project_in_the_given_directory, - paramType: Diagnostics.DIRECTORY + description: Diagnostics.Compile_the_project_in_the_given_directory_using_tsconfig_json_or_the_specified_config_file, + paramType: Diagnostics.DIRECTORY_OR_FILE }, { name: "removeComments", @@ -517,7 +517,7 @@ namespace ts { include: typeAcquisition.include || [], exclude: typeAcquisition.exclude || [] }; - return result; + return result; } return typeAcquisition; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ec5ca292b99..2230ffdbac0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2513,7 +2513,7 @@ "category": "Message", "code": 6019 }, - "Compile the project in the given directory.": { + "Compile the project in the given directory, using 'tsconfig.json' or the specified config file.": { "category": "Message", "code": 6020 }, @@ -2573,6 +2573,10 @@ "category": "Message", "code": 6039 }, + "DIRECTORY_OR_FILE": { + "category": "Message", + "code": 6040 + }, "Compilation complete. Watching for file changes.": { "category": "Message", "code": 6042 From 9017e0a084975913cbef1e8c69e55e8bf4e4083f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 7 Jan 2017 15:11:41 -0800 Subject: [PATCH 066/175] Allow missing argument for IIFE parameter with no type annotation --- src/compiler/checker.ts | 52 +++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 879be1c6fbf..61b1911261d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5058,9 +5058,10 @@ namespace ts { if (!links.resolvedSignature) { const parameters: Symbol[] = []; let hasLiteralTypes = false; - let minArgumentCount = -1; + let minArgumentCount = 0; let thisParameter: Symbol = undefined; let hasThisParameter: boolean; + const iife = getImmediatelyInvokedFunctionExpression(declaration); const isJSConstructSignature = isJSDocConstructSignature(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the @@ -5087,14 +5088,12 @@ namespace ts { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; + // Record a new minimum argument count if this is not an optional parameter + const isOptionalParameter = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param); + if (!isOptionalParameter) { + minArgumentCount = parameters.length; } } @@ -5109,13 +5108,6 @@ namespace ts { } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - const classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent).symbol)) : undefined; @@ -10933,23 +10925,23 @@ namespace ts { const func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { const iife = getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { const indexOfParameter = indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - const restTypes: Type[] = []; - for (let i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + const restTypes: Type[] = []; + for (let i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - const links = getNodeLinks(iife); - const cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - const type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + const links = getNodeLinks(iife); + const cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + const type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } const contextualSignature = getContextualSignature(func); if (contextualSignature) { From d2942b2b563529b9d9e7a5ed2d6b1981536ac17f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 7 Jan 2017 15:16:15 -0800 Subject: [PATCH 067/175] Accept new baselines --- .../reference/fixSignatureCaching.errors.txt | 1003 +---------------- 1 file changed, 2 insertions(+), 1001 deletions(-) diff --git a/tests/baselines/reference/fixSignatureCaching.errors.txt b/tests/baselines/reference/fixSignatureCaching.errors.txt index 6677afc174a..7a5c43c966e 100644 --- a/tests/baselines/reference/fixSignatureCaching.errors.txt +++ b/tests/baselines/reference/fixSignatureCaching.errors.txt @@ -1,4 +1,3 @@ -tests/cases/conformance/fixSignatureCaching.ts(3,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/fixSignatureCaching.ts(9,10): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(284,10): error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(293,10): error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. @@ -62,7 +61,6 @@ tests/cases/conformance/fixSignatureCaching.ts(961,57): error TS2339: Property ' tests/cases/conformance/fixSignatureCaching.ts(964,22): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. tests/cases/conformance/fixSignatureCaching.ts(968,18): error TS2339: Property '_impl' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. tests/cases/conformance/fixSignatureCaching.ts(970,18): error TS2339: Property 'version' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. -tests/cases/conformance/fixSignatureCaching.ts(974,4): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/fixSignatureCaching.ts(975,16): error TS2304: Cannot find name 'module'. tests/cases/conformance/fixSignatureCaching.ts(975,42): error TS2304: Cannot find name 'module'. tests/cases/conformance/fixSignatureCaching.ts(976,37): error TS2304: Cannot find name 'module'. @@ -73,2128 +71,1131 @@ 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 (73 errors) ==== +==== tests/cases/conformance/fixSignatureCaching.ts (71 errors) ==== // Repro from #10697 (function (define, undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ define(function () { - ~~~~~~~~~~~~~~~~~~~~ 'use strict'; - ~~~~~~~~~~~~~~~~~ - var impl = {}; - ~~~~~~~~~~~~~~~~~~ - impl.mobileDetectRules = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. "phones": { - ~~~~~~~~~~~~~~~ "iPhone": "\\biPhone\\b|\\biPod\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry": "BlackBerry|\\bBB10\\b|rim[0-9]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HTC": "HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Nexus": "Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Dell": "Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Motorola": "Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Samsung": "Samsung|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LG": "\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Sony": "SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Asus": "Asus.*Galaxy|PadFone.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaLumia": "Lumia [0-9]{3,4}", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Micromax": "Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Palm": "PalmSource|Palm", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Vertu": "Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Pantech": "PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Fly": "IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Wiko": "KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iMobile": "i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SimValley": "\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Wolfgang": "AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Alcatel": "Alcatel", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Nintendo": "Nintendo 3DS", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Amoi": "Amoi", - ~~~~~~~~~~~~~~~~~~~~~~~ "INQ": "INQ", - ~~~~~~~~~~~~~~~~~~~~~ "GenericPhone": "Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "tablets": { - ~~~~~~~~~~~~~~~~ "iPad": "iPad|iPad.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NexusTablet": "Android.*Nexus[\\s]+(7|9|10)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SamsungTablet": "SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Kindle": "Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SurfaceTablet": "Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HPTablet": "HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AsusTablet": "^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K017 |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerryTablet": "PlayBook|RIM Tablet", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HTCtablet": "HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MotorolaTablet": "xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NookTablet": "Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AcerTablet": "Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ToshibaTablet": "Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LGTablet": "\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FujitsuTablet": "Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PrestigioTablet": "PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LenovoTablet": "Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DellTablet": "Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "YarvikTablet": "Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MedionTablet": "Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ArnovaTablet": "AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IntensoTablet": "INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IRUTablet": "M702pro", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MegafonTablet": "MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EbodaTablet": "E-Boda (Supreme|Impresspeed|Izzycomm|Essential)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AllViewTablet": "Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ArchosTablet": "\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AinolTablet": "NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaLumiaTablet": "Lumia 2520", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SonyTablet": "Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP612|SOT31", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PhilipsTablet": "\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CubeTablet": "Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CobyTablet": "MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MIDTablet": "M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MSITablet": "MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SMiTTablet": "Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "RockChipTablet": "Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FlyTablet": "IQ310|Fly Vision", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "bqTablet": "Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris E10)|Maxwell.*Lite|Maxwell.*Plus", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HuaweiTablet": "MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NecTablet": "\\bN-06D|\\bN-08D", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PantechTablet": "Pantech.*P4100", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BronchoTablet": "Broncho.*(N701|N708|N802|a710)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VersusTablet": "TOUCHPAD.*[78910]|\\bTOUCHTAB\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ZyncTablet": "z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PositivoTablet": "TB07STA|TB10STA|TB07FTA|TB10FTA", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NabiTablet": "Android.*\\bNabi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KoboTablet": "Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DanewTablet": "DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TexetTablet": "NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PlaystationTablet": "Playstation.*(Portable|Vita)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TrekstorTablet": "ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PyleAudioTablet": "\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AdvanTablet": "Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DanyTechTablet": "Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GalapadTablet": "Android.*\\bG1\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MicromaxTablet": "Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KarbonnTablet": "Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AllFineTablet": "Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PROSCANTablet": "\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "YONESTablet": "BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ChangJiaTablet": "TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GUTablet": "TX-A1301|TX-M9002|Q702|kf026", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PointOfViewTablet": "TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OvermaxTablet": "OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HCLTablet": "HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DPSTablet": "DPS Dream 9|DPS Dual 7", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VistureTablet": "V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CrestaTablet": "CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MediatekTablet": "\\bMT8125|MT8389|MT8135|MT8377\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ConcordeTablet": "Concorde([ ]+)?Tab|ConCorde ReadMan", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GoCleverTablet": "GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ModecomTablet": "FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VoninoTablet": "\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ECSTablet": "V07OT2|TM105A|S10OT1|TR10CS1", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "StorexTablet": "eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VodafoneTablet": "SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EssentielBTablet": "Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "RossMoorTablet": "RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iMobileTablet": "i-mobile i-note", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TolinoTablet": "tolino tab [0-9.]+|tolino shine", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AudioSonicTablet": "\\bC-22Q|T7-QC|T-17B|T-17P\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AMPETablet": "Android.* A78 ", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SkkTablet": "Android.* (SKYPAD|PHOENIX|CYCLOPS)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TecnoTablet": "TECNO P9", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JXDTablet": "Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iJoyTablet": "Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FX2Tablet": "FX2 PAD7|FX2 PAD10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "XoroTablet": "KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ViewsonicTablet": "ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OdysTablet": "LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CaptivaTablet": "CAPTIVA PAD", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IconbitTablet": "NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TeclastTablet": "T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OndaTablet": "\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JaytechTablet": "TPC-PA762", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlaupunktTablet": "Endeavour 800NG|Endeavour 1010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DigmaTablet": "\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EvolioTablet": "ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LavaTablet": "QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AocTablet": "MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MpmanTablet": "MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CelkonTablet": "CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WolderTablet": "miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MiTablet": "\\bMI PAD\\b|\\bHM NOTE 1W\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NibiruTablet": "Nibiru M1|Nibiru Jupiter One", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NexoTablet": "NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LeaderTablet": "TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "UbislateTablet": "UbiSlate[\\s]?7C", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PocketBookTablet": "Pocketbook", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KocasoTablet": "\\b(TB-1207)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Hudl": "Hudl HT7S3|Hudl 2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TelstraTablet": "T-Hub2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GenericTablet": "Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bJolla\\b|\\bTP750\\b" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "oss": { - ~~~~~~~~~~~~ "AndroidOS": "Android", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerryOS": "blackberry|\\bBB10\\b|rim tablet os", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PalmOS": "PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SymbianOS": "Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WindowsMobileOS": "Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WindowsPhoneOS": "Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iOS": "\\biPhone.*Mobile|\\biPod|\\biPad", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MeeGoOS": "MeeGo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MaemoOS": "Maemo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JavaOS": "J2ME\/|\\bMIDP\\b|\\bCLDC\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "webOS": "webOS|hpwOS", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "badaOS": "\\bBada\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BREWOS": "BREW" - ~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "uas": { - ~~~~~~~~~~~~ "Vivaldi": "Vivaldi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Chrome": "\\bCrMo\\b|CriOS|Android.*Chrome\/[.0-9]* (Mobile)?", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Dolfin": "\\bDolfin\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera": "Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+|Coast\/[0-9.]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Skyfire": "Skyfire", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Edge": "Mobile Safari\/[.0-9]* Edge", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IE": "IEMobile|MSIEMobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Firefox": "fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Bolt": "bolt", - ~~~~~~~~~~~~~~~~~~~~~~~ "TeaShark": "teashark", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Blazer": "Blazer", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari": "Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Tizen": "Tizen", - ~~~~~~~~~~~~~~~~~~~~~~~~~ "UCBrowser": "UC.*Browser|UCWEB", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baiduboxapp": "baiduboxapp", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baidubrowser": "baidubrowser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DiigoBrowser": "DiigoBrowser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Puffin": "Puffin", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Mercury": "\\bMercury\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ObigoBrowser": "Obigo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NetFront": "NF-Browser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GenericBrowser": "NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PaleMoon": "Android.*PaleMoon|Mobile.*PaleMoon" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "props": { - ~~~~~~~~~~~~~~ "Mobile": "Mobile\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Build": "Build\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version": "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VendorID": "VendorID\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPad": "iPad.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPhone": "iPhone.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPod": "iPod.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Kindle": "Kindle\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Chrome": [ - ~~~~~~~~~~~~~~~~~~~ "Chrome\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CriOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CrMo\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Coast": [ - ~~~~~~~~~~~~~~~~~~ "Coast\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Dolfin": "Dolfin\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Firefox": "Firefox\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Fennec": "Fennec\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Edge": "Edge\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IE": [ - ~~~~~~~~~~~~~~~ "IEMobile\/[VER];", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IEMobile [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MSIE [VER];", - ~~~~~~~~~~~~~~~~~~~~~~~~~~ "Trident\/[0-9.]+;.*rv:[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "NetFront": "NetFront\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaBrowser": "NokiaBrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera": [ - ~~~~~~~~~~~~~~~~~~ " OPR\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera Mini\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Opera Mini": "Opera Mini\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera Mobi": "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "UC Browser": "UC Browser[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MQQBrowser": "MQQBrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MicroMessenger": "MicroMessenger\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baiduboxapp": "baiduboxapp\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baidubrowser": "baidubrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Iron": "Iron\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari": [ - ~~~~~~~~~~~~~~~~~~~ "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Skyfire": "Skyfire\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Tizen": "Tizen\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Webkit": "webkit[ \/][VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PaleMoon": "PaleMoon\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Gecko": "Gecko\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Trident": "Trident\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Presto": "Presto\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Goanna": "Goanna\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iOS": " \\bi?OS\\b [VER][ ;]{1}", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Android": "Android [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry": [ - ~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry[\\w]+\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry.*Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "BREW": "BREW [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Java": "Java\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone OS": [ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone OS [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone [VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Windows Phone": "Windows Phone [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows CE": "Windows CE\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows NT": "Windows NT [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Symbian": [ - ~~~~~~~~~~~~~~~~~~~~ "SymbianOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Symbian\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "webOS": [ - ~~~~~~~~~~~~~~~~~~ "webOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "hpwOS\/[VER];" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ] - ~~~~~~~~~ }, - ~~~~~~ "utils": { - ~~~~~~~~~~~~~~ "Bot": "Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MobileBot": "Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker\/M1A1-R2D2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DesktopMode": "WPDesktop", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TV": "SonyDTV|HbbTV", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WebKit": "(webkit)[ \/]([\\w.]+)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Console": "\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Watch": "SM-V700" - ~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ }; - ~~ - // following patterns come from http://detectmobilebrowsers.com/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.detectMobileBrowsers = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. fullPattern: /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ shortPattern: /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tabletPattern: /android|ipad|playbook|silk/i - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - var hasOwnProp = Object.prototype.hasOwnProperty, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ isArray; - ~~~~~~~~~~~~~~~~ - impl.FALLBACK_PHONE = 'UnknownPhone'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. impl.FALLBACK_TABLET = 'UnknownTablet'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. impl.FALLBACK_MOBILE = 'UnknownMobile'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_MOBILE' does not exist on type '{}'. - isArray = ('isArray' in Array) ? - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Array.isArray : function (value) { return Object.prototype.toString.call(value) === '[object Array]'; }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - function equalIC(a, b) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return a != null && b != null && a.toLowerCase() === b.toLowerCase(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - function containsIC(array, value) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var valueLC, i, len = array.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!len || !value) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return false; - ~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ valueLC = value.toLowerCase(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (valueLC === array[i].toLowerCase()) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return true; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return false; - ~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - function convertPropsToRegExp(object) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (var key in object) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(object, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ object[key] = new RegExp(object[key], 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ } - ~~~~~ - (function init() { - ~~~~~~~~~~~~~~~~~~~~~~ var key, values, value, i, len, verPos, mobileDetectRules = impl.mobileDetectRules; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. for (key in mobileDetectRules.props) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(mobileDetectRules.props, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ values = mobileDetectRules.props[key]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!isArray(values)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ values = [values]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ len = values.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = values[i]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ verPos = value.indexOf('[VER]'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (verPos >= 0) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = value.substring(0, verPos) + '([\\w._\\+]+)' + value.substring(verPos + 5); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~~~~~ values[i] = new RegExp(value, 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ mobileDetectRules.props[key] = values; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.oss); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.phones); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.tablets); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.uas); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.utils); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // copy some patterns to oss0 which are tested first (see issue#15) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mobileDetectRules.oss0 = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WindowsPhoneOS: mobileDetectRules.oss.WindowsPhoneOS, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WindowsMobileOS: mobileDetectRules.oss.WindowsMobileOS - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~~~~~ }()); - ~~~~~~~~~ - /** - ~~~~~~~ * Test userAgent string against a set of rules and find the first matched key. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Object} rules (key is String, value is RegExp) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent the navigator.userAgent (or HTTP-Header 'User-Agent'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {String|null} the matched key if found, otherwise null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.findMatch = function(rules, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. for (var key in rules) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(rules, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (rules[key].test(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return key; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return null; - ~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Test userAgent string against a set of rules and return an array of matched keys. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Object} rules (key is String, value is RegExp) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent the navigator.userAgent (or HTTP-Header 'User-Agent'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {Array} an array of matched keys, may be empty when there is no match, but not null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.findMatches = function(rules, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. var result = []; - ~~~~~~~~~~~~~~~~~~~~~~~~ for (var key in rules) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(rules, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (rules[key].test(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ result.push(key); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return result; - ~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Check the version of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} propertyName - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {String} version or null if version not found - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.getVersionStr = function (propertyName, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. var props = impl.mobileDetectRules.props, patterns, i, len, match; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (hasOwnProp.call(props, propertyName)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ patterns = props[propertyName]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ len = patterns.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ match = patterns[i].exec(userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (match !== null) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return match[1]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return null; - ~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Check the version of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} propertyName - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {Number} version or NaN if version not found - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.getVersion = function (propertyName, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ !!! error TS2339: Property 'getVersion' does not exist on type '{}'. var version = impl.getVersionStr(propertyName, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. return version ? impl.prepareVersionNo(version) : NaN; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareVersionNo' does not exist on type '{}'. }; - ~~~~~~ - /** - ~~~~~~~ * Prepare the version number. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} version - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {Number} the version number as a floating number - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.prepareVersionNo = function (version) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareVersionNo' does not exist on type '{}'. var numbers; - ~~~~~~~~~~~~~~~~~~~~ - numbers = version.split(/[a-z._ \/\-]/i); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (numbers.length === 1) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version = numbers[0]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ if (numbers.length > 1) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version = numbers[0] + '.'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ numbers.shift(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version += numbers.join(''); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ return Number(version); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - impl.isMobileFallback = function (userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isMobileFallback' does not exist on type '{}'. return impl.detectMobileBrowsers.fullPattern.test(userAgent) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. impl.detectMobileBrowsers.shortPattern.test(userAgent.substr(0,4)); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. }; - ~~~~~~ - impl.isTabletFallback = function (userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isTabletFallback' does not exist on type '{}'. return impl.detectMobileBrowsers.tabletPattern.test(userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. }; - ~~~~~~ - impl.prepareDetectionCache = function (cache, userAgent, maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. if (cache.mobile !== undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; - ~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ var phone, tablet, phoneSized; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // first check for stronger tablet rules, then phone (see issue#5) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tablet = impl.findMatch(impl.mobileDetectRules.tablets, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (tablet) { - ~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = tablet; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; // unambiguously identified as tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - phone = impl.findMatch(impl.mobileDetectRules.phones, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (phone) { - ~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.phone = phone; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.tablet = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; // unambiguously identified as phone - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - // our rules haven't found a match -> try more general fallback rules - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (impl.isMobileFallback(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isMobileFallback' does not exist on type '{}'. phoneSized = MobileDetect.isPhoneSized(maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. if (phoneSized === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = impl.FALLBACK_MOBILE; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_MOBILE' does not exist on type '{}'. cache.tablet = cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else if (phoneSized) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.phone = impl.FALLBACK_PHONE; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. cache.tablet = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else { - ~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = impl.FALLBACK_TABLET; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } else if (impl.isTabletFallback(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isTabletFallback' does not exist on type '{}'. cache.mobile = cache.tablet = impl.FALLBACK_TABLET; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else { - ~~~~~~~~~~~~~~~~ // not mobile at all! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ }; - ~~~~~~ - // t is a reference to a MobileDetect instance - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.mobileGrade = function (t) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'mobileGrade' does not exist on type '{}'. // impl note: - ~~~~~~~~~~~~~~~~~~~~~ // To keep in sync w/ Mobile_Detect.php easily, the following code is tightly aligned to the PHP version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // When changes are made in Mobile_Detect.php, copy this method and replace: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // $this-> / t. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // self::MOBILE_GRADE_(.) / '$1' - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // , self::VERSION_TYPE_FLOAT / (nothing) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // isIOS() / os('iOS') - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // [reg] / (nothing) <-- jsdelivr complaining about unescaped unicode character U+00AE - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var $isMobile = t.mobile() !== null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if ( - ~~~~~~~~~~~~ // Apple iOS 3.2-5.1 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), iPad 3 (5.1), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.1) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPad')>=4.3 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPhone')>=3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPod')>=3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('Android')>2.1 && t.is('Webkit') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Windows Phone OS')>=7.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Blackberry 7 - Tested on BlackBerry Torch 9810 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Blackberry 6.0 - Tested on the Torch 9800 and Style 9670 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('BlackBerry') && t.version('BlackBerry')>=6.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Blackberry Playbook (1.0-2.0) - Tested on PlayBook - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('Playbook.*Tablet') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Palm WebOS (1.4-2.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('webOS')>=1.4 && t.match('Palm|Pre|Pixi') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Palm WebOS 3.0 - Tested on HP TouchPad - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('hp.*TouchPad') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Firefox Mobile (12 Beta) - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Firefox') && t.version('Firefox')>=12 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Chrome for Android - Tested on Android 4.0, 4.1 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Chrome') && t.is('AndroidOS') && t.version('Android')>=4.0 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Skyfire 4.1 - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Skyfire') && t.version('Skyfire')>=4.1 && t.is('AndroidOS') && t.version('Android')>=2.3 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Opera Mobile 11.5-12: Tested on Android 2.3 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Opera') && t.version('Opera Mobi')>11 && t.is('AndroidOS') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Meego 1.2 - Tested on Nokia 950 and N9 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('MeeGoOS') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Tizen (pre-release) - Tested on early hardware - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Tizen') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @todo: more tests here! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Dolfin') && t.version('Bada')>=2.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // UC Browser - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( (t.is('UC Browser') || t.is('Dolfin')) && t.version('Android')>=2.3 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Kindle 3 and Fire - Tested on the built-in WebKit browser for each - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.match('Kindle Fire') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Kindle') && t.version('Kindle')>=3.0 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('AndroidOS') && t.is('NookTablet') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Chrome Desktop 11-21 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Chrome')>=11 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Safari Desktop 4-5 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Safari')>=5.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Firefox Desktop 4-13 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Firefox')>=4.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('MSIE')>=7.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @reference: http://my.opera.com/community/openweb/idopera/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Opera')>=10 && !$isMobile - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ){ - ~~~~~~~~~~~~~~ return 'A'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - if ( - ~~~~~~~~~~~~ t.os('iOS') && t.version('iPad')<4.3 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPhone')<3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPod')<3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Blackberry') && t.version('BlackBerry')>=5 && t.version('BlackBerry')<6 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('Opera Mini')>=5.0 && t.version('Opera Mini')<=6.5 && - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (t.version('Android')>=2.3 || t.is('iOS')) ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // @todo: report this (tested on Nokia N71) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Opera Mobi')>=11 && t.is('SymbianOS') - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ){ - ~~~~~~~~~~~~~~ return 'B'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - if ( - ~~~~~~~~~~~~ // Blackberry 4.x - Tested on the Curve 8330 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('BlackBerry')<5.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Windows Mobile - Tested on the HTC Leo (WinMo 5.2) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('MSIEMobile|Windows CE.*Mobile') || t.version('Windows Mobile')<=5.2 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ){ - ~~~~~~~~~~~~~~ return 'C'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - //All older smartphone platforms and featurephones - Any device that doesn't support media queries - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //will receive the basic, C grade experience. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return 'C'; - ~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - impl.detectOS = function (ua) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ !!! error TS2339: Property 'detectOS' does not exist on type '{}'. return impl.findMatch(impl.mobileDetectRules.oss0, ua) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. impl.findMatch(impl.mobileDetectRules.oss, ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. }; - ~~~~~~ - impl.getDeviceSmallerSide = function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'. return window.screen.width < window.screen.height ? - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. ~~~~~~ !!! error TS2304: Cannot find name 'window'. window.screen.width : - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. window.screen.height; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. }; - ~~~~~~ - /** - ~~~~~~~ * Constructor for MobileDetect object. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~ * Such an object will keep a reference to the given user-agent string and cache most of the detect queries.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Find information how to download and install: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * github.com/hgoebl/mobile-detect.js/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~ * - ~~~~~~ * @example
-    ~~~~~~~~~~~~~~~~~~~~~
          *     var md = new MobileDetect(window.navigator.userAgent);
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *     if (md.mobile()) {
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *         location.href = (md.mobileGrade() === 'A') ? '/mobile/' : '/lynx/';
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *     }
-    ~~~~~~~~~~~~
          * 
- ~~~~~~~~~~~~~ * - ~~~~~~ * @param {string} userAgent typically taken from window.navigator.userAgent or http_header['User-Agent'] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {number} [maxPhoneWidth=600] only for browsers specify a value for the maximum - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * width of smallest device side (in logical "CSS" pixels) until a device detected as mobile will be handled - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * as phone. - ~~~~~~~~~~~~~~~~~~~~~~~ * This is only used in cases where the device cannot be classified as phone or tablet.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * See Declaring Tablet Layouts - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * for Android.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * If you provide a value < 0, then this "fuzzy" check is disabled. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @constructor - ~~~~~~~~~~~~~~~~~~~ * @global - ~~~~~~~~~~~~~~ */ - ~~~~~~~ function MobileDetect(userAgent, maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this.ua = userAgent || ''; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache = {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~ //600dp is typical 7" tablet minimum width - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this.maxPhoneWidth = maxPhoneWidth || 600; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - MobileDetect.prototype = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ constructor: MobileDetect, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected phone or tablet type or null if it is not a mobile device. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * For a list of possible return values see {@link MobileDetect#phone} and {@link MobileDetect#tablet}.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownPhone, UnknownTablet or - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get UnknownMobile here.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the phone family or tablet family, e.g. "Nexus". - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#mobile - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ mobile: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.mobile; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected phone type/family string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned tablet (family or producer) is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
iPhone, BlackBerry, HTC, Nexus, Dell, Motorola, Samsung, LG, Sony, Asus, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NokiaLumia, Micromax, Palm, Vertu, Pantech, Fly, Wiko, iMobile, SimValley, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Wolfgang, Alcatel, Nintendo, Amoi, INQ, GenericPhone
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownPhone or UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get null here, while {@link MobileDetect#mobile} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * will return UnknownMobile.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key of the phone family or producer, e.g. "iPhone" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#phone - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ phone: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.phone; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected tablet type/family string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned tablet (family or producer) is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
iPad, NexusTablet, SamsungTablet, Kindle, SurfaceTablet, HPTablet, AsusTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * BlackBerryTablet, HTCtablet, MotorolaTablet, NookTablet, AcerTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ToshibaTablet, LGTablet, FujitsuTablet, PrestigioTablet, LenovoTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DellTablet, YarvikTablet, MedionTablet, ArnovaTablet, IntensoTablet, IRUTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MegafonTablet, EbodaTablet, AllViewTablet, ArchosTablet, AinolTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NokiaLumiaTablet, SonyTablet, PhilipsTablet, CubeTablet, CobyTablet, MIDTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MSITablet, SMiTTablet, RockChipTablet, FlyTablet, bqTablet, HuaweiTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NecTablet, PantechTablet, BronchoTablet, VersusTablet, ZyncTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PositivoTablet, NabiTablet, KoboTablet, DanewTablet, TexetTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PlaystationTablet, TrekstorTablet, PyleAudioTablet, AdvanTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DanyTechTablet, GalapadTablet, MicromaxTablet, KarbonnTablet, AllFineTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PROSCANTablet, YONESTablet, ChangJiaTablet, GUTablet, PointOfViewTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * OvermaxTablet, HCLTablet, DPSTablet, VistureTablet, CrestaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MediatekTablet, ConcordeTablet, GoCleverTablet, ModecomTablet, VoninoTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ECSTablet, StorexTablet, VodafoneTablet, EssentielBTablet, RossMoorTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iMobileTablet, TolinoTablet, AudioSonicTablet, AMPETablet, SkkTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * TecnoTablet, JXDTablet, iJoyTablet, FX2Tablet, XoroTablet, ViewsonicTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * OdysTablet, CaptivaTablet, IconbitTablet, TeclastTablet, OndaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * JaytechTablet, BlaupunktTablet, DigmaTablet, EvolioTablet, LavaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * AocTablet, MpmanTablet, CelkonTablet, WolderTablet, MiTablet, NibiruTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NexoTablet, LeaderTablet, UbislateTablet, PocketBookTablet, KocasoTablet, Hudl, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * TelstraTablet, GenericTablet
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownTablet or UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get null here, while {@link MobileDetect#mobile} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * will return UnknownMobile.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key of the tablet family or producer, e.g. "SamsungTablet" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ tablet: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.tablet; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the (first) detected user-agent string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned user-agent is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Vivaldi, Chrome, Dolfin, Opera, Skyfire, Edge, IE, Firefox, Bolt, TeaShark, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Blazer, Safari, Tizen, UCBrowser, baiduboxapp, baidubrowser, DiigoBrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Puffin, Mercury, ObigoBrowser, NetFront, GenericBrowser, PaleMoon
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases calling {@link MobileDetect#userAgent} will be sufficient. But there are rare - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * cases where a mobile device pretends to be more than one particular browser. You can get the - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * list of all matches with {@link MobileDetect#userAgents} or check for a particular value by - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * providing one of the defined keys as first argument to {@link MobileDetect#is}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the detected user-agent or null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ userAgent: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.userAgent === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.userAgent = impl.findMatch(impl.mobileDetectRules.uas, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.userAgent; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns all detected user-agent strings. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The array is empty or contains one or more of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Vivaldi, Chrome, Dolfin, Opera, Skyfire, Edge, IE, Firefox, Bolt, TeaShark, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Blazer, Safari, Tizen, UCBrowser, baiduboxapp, baidubrowser, DiigoBrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Puffin, Mercury, ObigoBrowser, NetFront, GenericBrowser, PaleMoon
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases calling {@link MobileDetect#userAgent} will be sufficient. But there are rare - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * cases where a mobile device pretends to be more than one particular browser. You can get the - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * list of all matches with {@link MobileDetect#userAgents} or check for a particular value by - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * providing one of the defined keys as first argument to {@link MobileDetect#is}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {Array} the array of detected user-agent keys or [] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#userAgents - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ userAgents: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.userAgents === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.userAgents = impl.findMatches(impl.mobileDetectRules.uas, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.userAgents; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected operating system string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The operating system is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
AndroidOS, BlackBerryOS, PalmOS, SymbianOS, WindowsMobileOS, WindowsPhoneOS, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, MeeGoOS, MaemoOS, JavaOS, webOS, badaOS, BREWOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the detected operating system. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#os - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ os: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.os === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.os = impl.detectOS(this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ !!! error TS2339: Property 'detectOS' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.os; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Get the version (as Number) of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key a key defining a thing which has a version.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * You can use one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Mobile, Build, Version, VendorID, iPad, iPhone, iPod, Kindle, Chrome, Coast, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Dolfin, Firefox, Fennec, Edge, IE, NetFront, NokiaBrowser, Opera, Opera Mini, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Opera Mobi, UC Browser, MQQBrowser, MicroMessenger, baiduboxapp, baidubrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Iron, Safari, Skyfire, Tizen, Webkit, PaleMoon, Gecko, Trident, Presto, Goanna, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, Android, BlackBerry, BREW, Java, Windows Phone OS, Windows Phone, Windows - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * CE, Windows NT, Symbian, webOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {Number} the version as float or NaN if User-Agent doesn't contain this version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be careful when comparing this value with '==' operator! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#version - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ version: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return impl.getVersion(key, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ !!! error TS2339: Property 'getVersion' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Get the version (as String) of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key a key defining a thing which has a version.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * You can use one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Mobile, Build, Version, VendorID, iPad, iPhone, iPod, Kindle, Chrome, Coast, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Dolfin, Firefox, Fennec, Edge, IE, NetFront, NokiaBrowser, Opera, Opera Mini, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Opera Mobi, UC Browser, MQQBrowser, MicroMessenger, baiduboxapp, baidubrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Iron, Safari, Skyfire, Tizen, Webkit, PaleMoon, Gecko, Trident, Presto, Goanna, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, Android, BlackBerry, BREW, Java, Windows Phone OS, Windows Phone, Windows - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * CE, Windows NT, Symbian, webOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the "raw" version as String or null if User-Agent doesn't contain this version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @function MobileDetect#versionStr - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ versionStr: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return impl.getVersionStr(key, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Global test key against userAgent, os, phone, tablet and some other properties of userAgent string. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key the key (case-insensitive) of a userAgent, an operating system, phone or - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * tablet family.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * For a complete list of possible values, see {@link MobileDetect#userAgent}, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#os}, {@link MobileDetect#phone}, {@link MobileDetect#tablet}.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Additionally you have following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Bot, MobileBot, DesktopMode, TV, WebKit, Console, Watch
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {boolean} true when the given key is one of the defined keys of userAgent, os, phone, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * tablet or one of the listed additional keys, otherwise false - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#is - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ is: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return containsIC(this.userAgents(), key) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.os()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.phone()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.tablet()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ containsIC(impl.findMatches(impl.mobileDetectRules.utils, this.ua), key); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Do a quick test against navigator::userAgent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String|RegExp} pattern the pattern, either as String or RegExp - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * (a string will be converted to a case-insensitive RegExp). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {boolean} true when the pattern matches, otherwise false - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#match - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ match: function (pattern) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!(pattern instanceof RegExp)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pattern = new RegExp(pattern, 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ return pattern.test(this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Checks whether the mobile device can be considered as phone regarding screen.width. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * Obviously this method makes sense in browser environments only (not for Node.js)! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {number} [maxPhoneWidth] the maximum logical pixels (aka. CSS-pixels) to be considered as phone.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The argument is optional and if not present or falsy, the value of the constructor is taken. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {boolean|undefined} undefined if screen size wasn't detectable, else true - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * when screen.width is less or equal to maxPhoneWidth, otherwise false.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Will always return undefined server-side. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ isPhoneSized: function (maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return MobileDetect.isPhoneSized(maxPhoneWidth || this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the mobile grade ('A', 'B', 'C'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} one of the mobile grades ('A', 'B', 'C'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#mobileGrade - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ mobileGrade: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.grade === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.grade = impl.mobileGrade(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'mobileGrade' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.grade; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ }; - ~~~~~~ - // environment-dependent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (typeof window !== 'undefined' && window.screen) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. ~~~~~~ !!! error TS2304: Cannot find name 'window'. MobileDetect.isPhoneSized = function (maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. return maxPhoneWidth < 0 ? undefined : impl.getDeviceSmallerSide() <= maxPhoneWidth; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'. }; - ~~~~~~~~~~ } else { - ~~~~~~~~~~~~ MobileDetect.isPhoneSized = function () {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. } - ~~~~~ - // should not be replaced by a completely new object - just overwrite existing methods - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MobileDetect._impl = impl; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2339: Property '_impl' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. - ~~~~ MobileDetect.version = '1.3.3 2016-07-31'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~ !!! error TS2339: Property 'version' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. - return MobileDetect; - ~~~~~~~~~~~~~~~~~~~~~~~~ }); // end of call of define() - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })((function (undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~ if (typeof module !== 'undefined' && module.exports) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'module'. ~~~~~~ !!! error TS2304: Cannot find name 'module'. return function (factory) { module.exports = factory(); }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'module'. } else if (typeof define === 'function' && define.amd) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'define'. ~~~~~~ !!! error TS2304: Cannot find name 'define'. return define; - ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'define'. } else if (typeof window !== 'undefined') { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. return function (factory) { window.MobileDetect = factory(); }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. } else { - ~~~~~~~~~~~~ - ~~~~~~~~~~~~ // please file a bug if you get this error! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ throw new Error('unknown environment'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - ~~~~~ - })()); - ~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - ~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file + })()); \ No newline at end of file From d0aa306961e5c8b4479d180bd2360dd5ac5c0444 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 7 Jan 2017 15:16:26 -0800 Subject: [PATCH 068/175] Add tests --- .../reference/contextuallyTypedIife.js | 6 + .../reference/contextuallyTypedIife.symbols | 11 + .../reference/contextuallyTypedIife.types | 19 ++ .../reference/contextuallyTypedIifeStrict.js | 110 +++++++ .../contextuallyTypedIifeStrict.symbols | 132 +++++++++ .../contextuallyTypedIifeStrict.types | 271 ++++++++++++++++++ .../functions/contextuallyTypedIife.ts | 3 + .../functions/contextuallyTypedIifeStrict.ts | 33 +++ 8 files changed, 585 insertions(+) create mode 100644 tests/baselines/reference/contextuallyTypedIifeStrict.js create mode 100644 tests/baselines/reference/contextuallyTypedIifeStrict.symbols create mode 100644 tests/baselines/reference/contextuallyTypedIifeStrict.types create mode 100644 tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts diff --git a/tests/baselines/reference/contextuallyTypedIife.js b/tests/baselines/reference/contextuallyTypedIife.js index d2eaaf9c2d5..0f3315d66a2 100644 --- a/tests/baselines/reference/contextuallyTypedIife.js +++ b/tests/baselines/reference/contextuallyTypedIife.js @@ -28,6 +28,9 @@ // contextually typed parameters. let twelve = (f => f(12))(i => i); let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); //// [contextuallyTypedIife.js] @@ -102,3 +105,6 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); // contextually typed parameters. var twelve = (function (f) { return f(12); })(function (i) { return i; }); var eleven = (function (o) { return o.a(11); })({ a: function (n) { return n; } }); +// missing arguments +(function (x, undefined) { return x; })(42); +(function (x, y, z) { return 42; })(); diff --git a/tests/baselines/reference/contextuallyTypedIife.symbols b/tests/baselines/reference/contextuallyTypedIife.symbols index 4512b4db8a2..7a73beaad16 100644 --- a/tests/baselines/reference/contextuallyTypedIife.symbols +++ b/tests/baselines/reference/contextuallyTypedIife.symbols @@ -119,3 +119,14 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); >n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42)) +// missing arguments +(function(x, undefined) { return x; })(42); +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 30, 10)) +>undefined : Symbol(undefined, Decl(contextuallyTypedIife.ts, 30, 12)) +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 30, 10)) + +((x, y, z) => 42)(); +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 31, 2)) +>y : Symbol(y, Decl(contextuallyTypedIife.ts, 31, 4)) +>z : Symbol(z, Decl(contextuallyTypedIife.ts, 31, 7)) + diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index e6f41265e9a..15038e7dd26 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -250,3 +250,22 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); >n : any >n : any +// missing arguments +(function(x, undefined) { return x; })(42); +>(function(x, undefined) { return x; })(42) : number +>(function(x, undefined) { return x; }) : (x: number, undefined: any) => number +>function(x, undefined) { return x; } : (x: number, undefined: any) => number +>x : number +>undefined : any +>x : number +>42 : 42 + +((x, y, z) => 42)(); +>((x, y, z) => 42)() : number +>((x, y, z) => 42) : (x: any, y: any, z: any) => number +>(x, y, z) => 42 : (x: any, y: any, z: any) => number +>x : any +>y : any +>z : any +>42 : 42 + diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.js b/tests/baselines/reference/contextuallyTypedIifeStrict.js new file mode 100644 index 00000000000..c5455ab84c8 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.js @@ -0,0 +1,110 @@ +//// [contextuallyTypedIifeStrict.ts] +// arrow +(jake => { })("build"); +// function expression +(function (cats) { })("lol"); +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +((((function (y) { }))))("-"); +// multiple arguments +((a, b, c) => { })("foo", 101, false); +// default parameters +((m = 10) => m + 1)(12); +((n = 10) => n + 1)(); +// optional parameters +((j?) => j + 1)(12); +((k?) => k + 1)(); +((l, o?) => l + o)(12); // o should be any +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +((...noNumbers) => noNumbers.some(n => n > 0))(); +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +(({ p = 14 }) => p)({ p : 15 }); +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +(({ u = 22 } = { u: 23 }) => u)(); +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); + + +//// [contextuallyTypedIifeStrict.js] +// arrow +(function (jake) { })("build"); +// function expression +(function (cats) { })("lol"); +// Lots of Irritating Superfluous Parentheses +(function (x) { }("!")); +((((function (y) { }))))("-"); +// multiple arguments +(function (a, b, c) { })("foo", 101, false); +// default parameters +(function (m) { + if (m === void 0) { m = 10; } + return m + 1; +})(12); +(function (n) { + if (n === void 0) { n = 10; } + return n + 1; +})(); +// optional parameters +(function (j) { return j + 1; })(12); +(function (k) { return k + 1; })(); +(function (l, o) { return l + o; })(12); // o should be any +// rest parameters +(function () { + var numbers = []; + for (var _i = 0; _i < arguments.length; _i++) { + numbers[_i] = arguments[_i]; + } + return numbers.every(function (n) { return n > 0; }); +})(5, 6, 7); +(function () { + var mixed = []; + for (var _i = 0; _i < arguments.length; _i++) { + mixed[_i] = arguments[_i]; + } + return mixed.every(function (n) { return !!n; }); +})(5, 'oops', 'oh no'); +(function () { + var noNumbers = []; + for (var _i = 0; _i < arguments.length; _i++) { + noNumbers[_i] = arguments[_i]; + } + return noNumbers.some(function (n) { return n > 0; }); +})(); +(function (first) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + return first ? [] : rest.map(function (n) { return n > 0; }); +})(8, 9, 10); +// destructuring parameters (with defaults too!) +(function (_a) { + var q = _a.q; + return q; +})({ q: 13 }); +(function (_a) { + var _b = _a.p, p = _b === void 0 ? 14 : _b; + return p; +})({ p: 15 }); +(function (_a) { + var _b = (_a === void 0 ? { r: 18 } : _a).r, r = _b === void 0 ? 17 : _b; + return r; +})({ r: 19 }); +(function (_a) { + var _b = (_a === void 0 ? { u: 23 } : _a).u, u = _b === void 0 ? 22 : _b; + return u; +})(); +// contextually typed parameters. +var twelve = (function (f) { return f(12); })(function (i) { return i; }); +var eleven = (function (o) { return o.a(11); })({ a: function (n) { return n; } }); +// missing arguments +(function (x, undefined) { return x; })(42); +(function (x, y, z) { return 42; })(); diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.symbols b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols new file mode 100644 index 00000000000..f76c9caa104 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols @@ -0,0 +1,132 @@ +=== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts === +// arrow +(jake => { })("build"); +>jake : Symbol(jake, Decl(contextuallyTypedIifeStrict.ts, 1, 1)) + +// function expression +(function (cats) { })("lol"); +>cats : Symbol(cats, Decl(contextuallyTypedIifeStrict.ts, 3, 11)) + +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 5, 11)) + +((((function (y) { }))))("-"); +>y : Symbol(y, Decl(contextuallyTypedIifeStrict.ts, 6, 14)) + +// multiple arguments +((a, b, c) => { })("foo", 101, false); +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 8, 2)) +>b : Symbol(b, Decl(contextuallyTypedIifeStrict.ts, 8, 4)) +>c : Symbol(c, Decl(contextuallyTypedIifeStrict.ts, 8, 7)) + +// default parameters +((m = 10) => m + 1)(12); +>m : Symbol(m, Decl(contextuallyTypedIifeStrict.ts, 10, 2)) +>m : Symbol(m, Decl(contextuallyTypedIifeStrict.ts, 10, 2)) + +((n = 10) => n + 1)(); +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 11, 2)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 11, 2)) + +// optional parameters +((j?) => j + 1)(12); +>j : Symbol(j, Decl(contextuallyTypedIifeStrict.ts, 13, 2)) +>j : Symbol(j, Decl(contextuallyTypedIifeStrict.ts, 13, 2)) + +((k?) => k + 1)(); +>k : Symbol(k, Decl(contextuallyTypedIifeStrict.ts, 14, 2)) +>k : Symbol(k, Decl(contextuallyTypedIifeStrict.ts, 14, 2)) + +((l, o?) => l + o)(12); // o should be any +>l : Symbol(l, Decl(contextuallyTypedIifeStrict.ts, 15, 2)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 15, 4)) +>l : Symbol(l, Decl(contextuallyTypedIifeStrict.ts, 15, 2)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 15, 4)) + +// 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 : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) +>every : Symbol(Array.every, 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 : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) +>every : Symbol(Array.every, 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 : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) +>some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) + +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +>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 : 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, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) + +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 3)) +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 3)) +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 16)) + +(({ p = 14 }) => p)({ p : 15 }); +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 3)) +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 3)) +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 21)) + +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 3)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 16)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 3)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 33)) + +(({ u = 22 } = { u: 23 }) => u)(); +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 3)) +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 16)) +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 3)) + +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +>twelve : Symbol(twelve, Decl(contextuallyTypedIifeStrict.ts, 27, 3)) +>f : Symbol(f, Decl(contextuallyTypedIifeStrict.ts, 27, 14)) +>f : Symbol(f, Decl(contextuallyTypedIifeStrict.ts, 27, 14)) +>i : Symbol(i, Decl(contextuallyTypedIifeStrict.ts, 27, 26)) +>i : Symbol(i, Decl(contextuallyTypedIifeStrict.ts, 27, 26)) + +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +>eleven : Symbol(eleven, Decl(contextuallyTypedIifeStrict.ts, 28, 3)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 28, 14)) +>o.a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 28, 14)) +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 28, 42)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 28, 42)) + +// missing arguments +(function(x, undefined) { return x; })(42); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 30, 10)) +>undefined : Symbol(undefined, Decl(contextuallyTypedIifeStrict.ts, 30, 12)) +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 30, 10)) + +((x, y, z) => 42)(); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 31, 2)) +>y : Symbol(y, Decl(contextuallyTypedIifeStrict.ts, 31, 4)) +>z : Symbol(z, Decl(contextuallyTypedIifeStrict.ts, 31, 7)) + diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types new file mode 100644 index 00000000000..cbeee53ec2e --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -0,0 +1,271 @@ +=== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts === +// arrow +(jake => { })("build"); +>(jake => { })("build") : void +>(jake => { }) : (jake: string) => void +>jake => { } : (jake: string) => void +>jake : string +>"build" : "build" + +// function expression +(function (cats) { })("lol"); +>(function (cats) { })("lol") : void +>(function (cats) { }) : (cats: string) => void +>function (cats) { } : (cats: string) => void +>cats : string +>"lol" : "lol" + +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +>(function (x) { } ("!")) : void +>function (x) { } ("!") : void +>function (x) { } : (x: string) => void +>x : string +>"!" : "!" + +((((function (y) { }))))("-"); +>((((function (y) { }))))("-") : void +>((((function (y) { })))) : (y: string) => void +>(((function (y) { }))) : (y: string) => void +>((function (y) { })) : (y: string) => void +>(function (y) { }) : (y: string) => void +>function (y) { } : (y: string) => void +>y : string +>"-" : "-" + +// multiple arguments +((a, b, c) => { })("foo", 101, false); +>((a, b, c) => { })("foo", 101, false) : void +>((a, b, c) => { }) : (a: string, b: number, c: boolean) => void +>(a, b, c) => { } : (a: string, b: number, c: boolean) => void +>a : string +>b : number +>c : boolean +>"foo" : "foo" +>101 : 101 +>false : false + +// default parameters +((m = 10) => m + 1)(12); +>((m = 10) => m + 1)(12) : number +>((m = 10) => m + 1) : (m?: number) => number +>(m = 10) => m + 1 : (m?: number) => number +>m : number +>10 : 10 +>m + 1 : number +>m : number +>1 : 1 +>12 : 12 + +((n = 10) => n + 1)(); +>((n = 10) => n + 1)() : number +>((n = 10) => n + 1) : (n?: number) => number +>(n = 10) => n + 1 : (n?: number) => number +>n : number +>10 : 10 +>n + 1 : number +>n : number +>1 : 1 + +// optional parameters +((j?) => j + 1)(12); +>((j?) => j + 1)(12) : number +>((j?) => j + 1) : (j?: number | undefined) => number +>(j?) => j + 1 : (j?: number | undefined) => number +>j : number | undefined +>j + 1 : number +>j : number | undefined +>1 : 1 +>12 : 12 + +((k?) => k + 1)(); +>((k?) => k + 1)() : number +>((k?) => k + 1) : (k?: undefined) => number +>(k?) => k + 1 : (k?: undefined) => number +>k : undefined +>k + 1 : number +>k : undefined +>1 : 1 + +((l, o?) => l + o)(12); // o should be any +>((l, o?) => l + o)(12) : number +>((l, o?) => l + o) : (l: number, o?: undefined) => number +>(l, o?) => l + o : (l: number, o?: undefined) => number +>l : number +>o : undefined +>l + o : number +>l : number +>o : undefined +>12 : 12 + +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +>((...numbers) => numbers.every(n => n > 0))(5,6,7) : boolean +>((...numbers) => numbers.every(n => n > 0)) : (...numbers: number[]) => boolean +>(...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 : number[] +>every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: number) => boolean +>n : number +>n > 0 : boolean +>n : number +>0 : 0 +>5 : 5 +>6 : 6 +>7 : 7 + +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +>((...mixed) => mixed.every(n => !!n))(5,'oops','oh no') : boolean +>((...mixed) => mixed.every(n => !!n)) : (...mixed: (string | number)[]) => boolean +>(...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 : (string | number)[] +>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>n => !!n : (n: string | number) => boolean +>n : string | number +>!!n : boolean +>!n : boolean +>n : string | number +>5 : 5 +>'oops' : "oops" +>'oh no' : "oh no" + +((...noNumbers) => noNumbers.some(n => n > 0))(); +>((...noNumbers) => noNumbers.some(n => n > 0))() : boolean +>((...noNumbers) => noNumbers.some(n => n > 0)) : (...noNumbers: any[]) => boolean +>(...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 : any[] +>some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: any) => boolean +>n : any +>n > 0 : boolean +>n : any +>0 : 0 + +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +>((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : boolean[] +>((first, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, ...rest: number[]) => boolean[] +>(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, ...rest: number[]) => boolean[] +>first : number +>rest : number[] +>first ? [] : rest.map(n => n > 0) : boolean[] +>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 : 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 +>n : number +>n > 0 : boolean +>n : number +>0 : 0 +>8 : 8 +>9 : 9 +>10 : 10 + +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +>(({ q }) => q)({ q : 13 }) : number +>(({ q }) => q) : ({q}: { q: number; }) => number +>({ q }) => q : ({q}: { q: number; }) => number +>q : number +>q : number +>{ q : 13 } : { q: number; } +>q : number +>13 : 13 + +(({ p = 14 }) => p)({ p : 15 }); +>(({ p = 14 }) => p)({ p : 15 }) : number +>(({ p = 14 }) => p) : ({p}: { p: number; }) => number +>({ p = 14 }) => p : ({p}: { p: number; }) => number +>p : number +>14 : 14 +>p : number +>{ p : 15 } : { p: number; } +>p : number +>15 : 15 + +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +>(({ r = 17 } = { r: 18 }) => r)({r : 19}) : number +>(({ r = 17 } = { r: 18 }) => r) : ({r}?: { r: number; }) => number +>({ r = 17 } = { r: 18 }) => r : ({r}?: { r: number; }) => number +>r : number +>17 : 17 +>{ r: 18 } : { r: number; } +>r : number +>18 : 18 +>r : number +>{r : 19} : { r: number; } +>r : number +>19 : 19 + +(({ u = 22 } = { u: 23 }) => u)(); +>(({ u = 22 } = { u: 23 }) => u)() : number +>(({ u = 22 } = { u: 23 }) => u) : ({u}?: { u?: number; }) => number +>({ u = 22 } = { u: 23 }) => u : ({u}?: { u?: number; }) => number +>u : number +>22 : 22 +>{ u: 23 } : { u?: number; } +>u : number +>23 : 23 +>u : number + +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +>twelve : any +>(f => f(12))(i => i) : any +>(f => f(12)) : (f: (i: any) => any) => any +>f => f(12) : (f: (i: any) => any) => any +>f : (i: any) => any +>f(12) : any +>f : (i: any) => any +>12 : 12 +>i => i : (i: any) => any +>i : any +>i : any + +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +>eleven : any +>(o => o.a(11))({ a: function(n) { return n; } }) : any +>(o => o.a(11)) : (o: { a: (n: any) => any; }) => any +>o => o.a(11) : (o: { a: (n: any) => any; }) => any +>o : { a: (n: any) => any; } +>o.a(11) : any +>o.a : (n: any) => any +>o : { a: (n: any) => any; } +>a : (n: any) => any +>11 : 11 +>{ a: function(n) { return n; } } : { a: (n: any) => any; } +>a : (n: any) => any +>function(n) { return n; } : (n: any) => any +>n : any +>n : any + +// missing arguments +(function(x, undefined) { return x; })(42); +>(function(x, undefined) { return x; })(42) : number +>(function(x, undefined) { return x; }) : (x: number, undefined: undefined) => number +>function(x, undefined) { return x; } : (x: number, undefined: undefined) => number +>x : number +>undefined : undefined +>x : number +>42 : 42 + +((x, y, z) => 42)(); +>((x, y, z) => 42)() : number +>((x, y, z) => 42) : (x: undefined, y: undefined, z: undefined) => number +>(x, y, z) => 42 : (x: undefined, y: undefined, z: undefined) => number +>x : undefined +>y : undefined +>z : undefined +>42 : 42 + diff --git a/tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts b/tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts index ed3c24e0ac7..ca0d6e67711 100644 --- a/tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts +++ b/tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts @@ -27,3 +27,6 @@ // contextually typed parameters. let twelve = (f => f(12))(i => i); let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); diff --git a/tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts b/tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts new file mode 100644 index 00000000000..04951beb9f0 --- /dev/null +++ b/tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts @@ -0,0 +1,33 @@ +// @strictNullChecks: true +// arrow +(jake => { })("build"); +// function expression +(function (cats) { })("lol"); +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +((((function (y) { }))))("-"); +// multiple arguments +((a, b, c) => { })("foo", 101, false); +// default parameters +((m = 10) => m + 1)(12); +((n = 10) => n + 1)(); +// optional parameters +((j?) => j + 1)(12); +((k?) => k + 1)(); +((l, o?) => l + o)(12); // o should be any +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +((...noNumbers) => noNumbers.some(n => n > 0))(); +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +(({ p = 14 }) => p)({ p : 15 }); +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +(({ u = 22 } = { u: 23 }) => u)(); +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); From 523aca204ab5d4b41ec52a134486edef627a9593 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 8 Jan 2017 15:21:09 -0800 Subject: [PATCH 069/175] Property track mapped types in combined type mappers --- src/compiler/checker.ts | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 879be1c6fbf..beb3d3dd297 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4606,7 +4606,7 @@ namespace ts { // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. - const iterationMapper = createUnaryTypeMapper(typeParameter, t); + const iterationMapper = createTypeMapper([typeParameter], [t]); const templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; const propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. @@ -4666,7 +4666,7 @@ namespace ts { } function getErasedTemplateTypeFromMappedType(type: MappedType) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); + return instantiateType(getTemplateTypeFromMappedType(type), createTypeEraser([getTypeParameterFromMappedType(type)])); } function isGenericMappedType(type: Type) { @@ -6135,7 +6135,7 @@ namespace ts { error(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - const mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + const mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); const templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } @@ -6502,16 +6502,16 @@ namespace ts { return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source: Type, target: Type): TypeMapper { - return t => t === source ? target : t; + function makeUnaryTypeMapper(source: Type, target: Type) { + return (t: Type) => t === source ? target : t; } - function createBinaryTypeMapper(source1: Type, target1: Type, source2: Type, target2: Type): TypeMapper { - return t => t === source1 ? target1 : t === source2 ? target2 : t; + function makeBinaryTypeMapper(source1: Type, target1: Type, source2: Type, target2: Type) { + return (t: Type) => t === source1 ? target1 : t === source2 ? target2 : t; } - function createArrayTypeMapper(sources: Type[], targets: Type[]): TypeMapper { - return t => { + function makeArrayTypeMapper(sources: Type[], targets: Type[]) { + return (t: Type) => { for (let i = 0; i < sources.length; i++) { if (t === sources[i]) { return targets ? targets[i] : anyType; @@ -6522,11 +6522,9 @@ namespace ts { } function createTypeMapper(sources: Type[], targets: Type[]): TypeMapper { - const count = sources.length; - const mapper: TypeMapper = - count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + const mapper: TypeMapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } @@ -6560,7 +6558,7 @@ namespace ts { function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper { const mapper: TypeMapper = t => instantiateType(mapper1(t), mapper2); - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = concatenate(mapper1.mappedTypes, mapper2.mappedTypes); return mapper; } @@ -6662,7 +6660,7 @@ namespace ts { if (typeVariable !== mappedTypeVariable) { return mapType(mappedTypeVariable, t => { if (isMappableType(t)) { - const replacementMapper = createUnaryTypeMapper(typeVariable, t); + const replacementMapper = createTypeMapper([typeVariable], [t]); const combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); combinedMapper.mappedTypes = mapper.mappedTypes; return instantiateMappedObjectType(type, combinedMapper); From 70763dabb5d98e4b4d10683864410b6f2b4d4c5c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 8 Jan 2017 15:28:38 -0800 Subject: [PATCH 070/175] Add regression test --- .../mappedTypeNestedGenericInstantiation.js | 19 ++++++ ...ppedTypeNestedGenericInstantiation.symbols | 50 ++++++++++++++++ ...mappedTypeNestedGenericInstantiation.types | 58 +++++++++++++++++++ .../mappedTypeNestedGenericInstantiation.ts | 12 ++++ 4 files changed, 139 insertions(+) create mode 100644 tests/baselines/reference/mappedTypeNestedGenericInstantiation.js create mode 100644 tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols create mode 100644 tests/baselines/reference/mappedTypeNestedGenericInstantiation.types create mode 100644 tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js new file mode 100644 index 00000000000..f70130a84d5 --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js @@ -0,0 +1,19 @@ +//// [mappedTypeNestedGenericInstantiation.ts] +// Repro from #13346 + +interface Chainable { + value(): T; + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +} + +declare function chain(t: T): Chainable; + +const square = (x: number) => x * x; + +const v = chain({a: 1, b: 2}).mapValues(square).value(); + + +//// [mappedTypeNestedGenericInstantiation.js] +// Repro from #13346 +var square = function (x) { return x * x; }; +var v = chain({ a: 1, b: 2 }).mapValues(square).value(); diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols new file mode 100644 index 00000000000..0ec4f50bedc --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols @@ -0,0 +1,50 @@ +=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts === +// Repro from #13346 + +interface Chainable { +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) + + value(): T; +>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) + + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +>func : Symbol(func, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 15)) +>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 22)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>k : Symbol(k, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 56)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +} + +declare function chain(t: T): Chainable; +>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) +>t : Symbol(t, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 26)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) + +const square = (x: number) => x * x; +>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) + +const v = chain({a: 1, b: 2}).mapValues(square).value(); +>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 5)) +>chain({a: 1, b: 2}).mapValues(square).value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) +>chain({a: 1, b: 2}).mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1)) +>a : Symbol(a, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 17)) +>b : Symbol(b, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 22)) +>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5)) +>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) + diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types new file mode 100644 index 00000000000..7501bdb19e8 --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts === +// Repro from #13346 + +interface Chainable { +>Chainable : Chainable +>T : T + + value(): T; +>value : () => T +>T : T + + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +>mapValues : (func: (v: T[keyof T]) => U) => Chainable<{ [k in keyof T]: U; }> +>U : U +>func : (v: T[keyof T]) => U +>v : T[keyof T] +>T : T +>T : T +>U : U +>Chainable : Chainable +>k : k +>T : T +>U : U +} + +declare function chain(t: T): Chainable; +>chain : (t: T) => Chainable +>T : T +>t : T +>T : T +>Chainable : Chainable +>T : T + +const square = (x: number) => x * x; +>square : (x: number) => number +>(x: number) => x * x : (x: number) => number +>x : number +>x * x : number +>x : number +>x : number + +const v = chain({a: 1, b: 2}).mapValues(square).value(); +>v : { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square).value() : { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square).value : () => { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square) : Chainable<{ a: number; b: number; }> +>chain({a: 1, b: 2}).mapValues : (func: (v: number) => U) => Chainable<{ a: U; b: U; }> +>chain({a: 1, b: 2}) : Chainable<{ a: number; b: number; }> +>chain : (t: T) => Chainable +>{a: 1, b: 2} : { a: number; b: number; } +>a : number +>1 : 1 +>b : number +>2 : 2 +>mapValues : (func: (v: number) => U) => Chainable<{ a: U; b: U; }> +>square : (x: number) => number +>value : () => { a: number; b: number; } + diff --git a/tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts b/tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts new file mode 100644 index 00000000000..8901c215115 --- /dev/null +++ b/tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts @@ -0,0 +1,12 @@ +// Repro from #13346 + +interface Chainable { + value(): T; + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +} + +declare function chain(t: T): Chainable; + +const square = (x: number) => x * x; + +const v = chain({a: 1, b: 2}).mapValues(square).value(); From a0b417d1beeb8f3b87a0bf37df09e443f1f2000c Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 9 Jan 2017 06:31:17 -0800 Subject: [PATCH 071/175] Fix gulp-typescript version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fdb85ea764b..c49162343a2 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "gulp-insert": "latest", "gulp-newer": "latest", "gulp-sourcemaps": "latest", - "gulp-typescript": "latest", + "gulp-typescript": "3.1.3", "into-stream": "latest", "istanbul": "latest", "jake": "latest", From c28d98a1468f9a0541dd4ac64bebcd96d18fe289 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 9 Jan 2017 06:36:07 -0800 Subject: [PATCH 072/175] Fix test --- ...eFixClassImplementInterfaceComputedPropertyLiterals.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts index 465f9a5b4f1..341b4e59814 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts @@ -10,12 +10,12 @@ //// class C implements I {[| |]} verify.rangeAfterCodeFix(` - [1](): string { - throw new Error('Method not implemented.'); - } - [2]: boolean; ["foo"](o: any): boolean { throw new Error('Method not implemented.'); } ["x"]: boolean; + [1](): string { + throw new Error('Method not implemented.'); + } + [2]: boolean; `); \ No newline at end of file From c1b55a9e05f0986306e8d209b67028475ac9aa6c Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 9 Jan 2017 06:58:07 -0800 Subject: [PATCH 073/175] Fix linting --- src/compiler/moduleNameResolver.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index e915103f3ce..7ab65515378 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -357,7 +357,7 @@ namespace ts { * Then it computes the set of parent folders for 'directory' that should have the same module resolution result * and for every parent folder in set it adds entry: parent -> module resolution. . * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. - * Set of parent folders that should have the same result will be: + * Set of parent folders that should have the same result will be: * [ * /a/b/c/d, /a/b/c, /a/b * ] @@ -391,7 +391,7 @@ namespace ts { } } } - + function getCommonPrefix(directory: Path, resolution: string) { if (resolution === undefined) { return undefined; @@ -421,7 +421,7 @@ namespace ts { trace(host, Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } const containingDirectory = getDirectoryPath(containingFile); - let perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); let result = perFolderCache && perFolderCache[moduleName]; if (result) { @@ -1022,7 +1022,7 @@ namespace ts { /** * Represents result of search. Normally when searching among several alternatives we treat value `undefined` as indicator - * that search fails and we should try another option. + * that search fails and we should try another option. * However this does not allow us to represent final result that should be used instead of further searching (i.e. a final result that was found in cache). * SearchResult is used to deal with this issue, its values represents following outcomes: * - undefined - not found, continue searching @@ -1030,7 +1030,7 @@ namespace ts { * - { value: } - found - stop searching */ type SearchResult = { value: T | undefined } | undefined; - + /** * Wraps value to SearchResult. * @returns undefined if value is undefined or { value } otherwise From 23fa422b590c7ff1317f0e294a04e91d91cfca31 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 9 Jan 2017 07:47:52 -0800 Subject: [PATCH 074/175] String literal completions: Use call signature only if we are *immediately* in a call expression --- src/compiler/moduleNameResolver.ts | 10 ++--- src/services/completions.ts | 38 +++++++++---------- src/services/signatureHelp.ts | 2 +- .../fourslash/completionForStringLiteral6.ts | 12 ++++++ tests/webTestServer.ts | 2 +- 5 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteral6.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index e915103f3ce..e95c96220b8 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -15,7 +15,7 @@ namespace ts { } /** Array that is only intended to be pushed to, never read. */ - interface Push { + export interface Push { push(value: T): void; } @@ -357,7 +357,7 @@ namespace ts { * Then it computes the set of parent folders for 'directory' that should have the same module resolution result * and for every parent folder in set it adds entry: parent -> module resolution. . * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. - * Set of parent folders that should have the same result will be: + * Set of parent folders that should have the same result will be: * [ * /a/b/c/d, /a/b/c, /a/b * ] @@ -391,7 +391,7 @@ namespace ts { } } } - + function getCommonPrefix(directory: Path, resolution: string) { if (resolution === undefined) { return undefined; @@ -1022,7 +1022,7 @@ namespace ts { /** * Represents result of search. Normally when searching among several alternatives we treat value `undefined` as indicator - * that search fails and we should try another option. + * that search fails and we should try another option. * However this does not allow us to represent final result that should be used instead of further searching (i.e. a final result that was found in cache). * SearchResult is used to deal with this issue, its values represents following outcomes: * - undefined - not found, continue searching @@ -1030,7 +1030,7 @@ namespace ts { * - { value: } - found - stop searching */ type SearchResult = { value: T | undefined } | undefined; - + /** * Wraps value to SearchResult. * @returns undefined if value is undefined or { value } otherwise diff --git a/src/services/completions.ts b/src/services/completions.ts index f0daa696474..d893e7212ec 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,8 +1,6 @@ -/// - /* @internal */ namespace ts.Completions { - export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo { + export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo | undefined { if (isInReferenceComment(sourceFile, position)) { return getTripleSlashReferenceCompletion(sourceFile, position); } @@ -134,7 +132,7 @@ namespace ts.Completions { return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number) { + function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number): CompletionInfo | undefined { const node = findPrecedingToken(position, sourceFile); if (!node || node.kind !== SyntaxKind.StringLiteral) { return undefined; @@ -174,7 +172,7 @@ namespace ts.Completions { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { - const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); + const argumentInfo = SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); if (argumentInfo) { // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); @@ -188,7 +186,7 @@ namespace ts.Completions { } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement) { + function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement): CompletionInfo | undefined { const type = typeChecker.getContextualType((element.parent)); const entries: CompletionEntry[] = []; if (type) { @@ -199,7 +197,7 @@ namespace ts.Completions { } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo): CompletionInfo | undefined { const candidates: Signature[] = []; const entries: CompletionEntry[] = []; @@ -219,7 +217,7 @@ namespace ts.Completions { return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression) { + function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression): CompletionInfo | undefined { const type = typeChecker.getTypeAtLocation(node.expression); const entries: CompletionEntry[] = []; if (type) { @@ -231,7 +229,7 @@ namespace ts.Completions { return undefined; } - function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral) { + function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral): CompletionInfo | undefined { const type = typeChecker.getContextualType(node); if (type) { const entries: CompletionEntry[] = []; @@ -243,7 +241,7 @@ namespace ts.Completions { return undefined; } - function addStringLiteralCompletionsFromType(type: Type, result: CompletionEntry[]): void { + function addStringLiteralCompletionsFromType(type: Type, result: Push): void { if (type && type.flags & TypeFlags.TypeParameter) { type = typeChecker.getApparentType(type); } @@ -251,18 +249,18 @@ namespace ts.Completions { return; } if (type.flags & TypeFlags.Union) { - forEach((type).types, t => addStringLiteralCompletionsFromType(t, result)); - } - else { - if (type.flags & TypeFlags.StringLiteral) { - result.push({ - name: (type).text, - kindModifiers: ScriptElementKindModifier.none, - kind: ScriptElementKind.variableElement, - sortText: "0" - }); + for (const t of (type).types) { + addStringLiteralCompletionsFromType(t, result); } } + else if (type.flags & TypeFlags.StringLiteral) { + result.push({ + name: (type).text, + kindModifiers: ScriptElementKindModifier.none, + kind: ScriptElementKind.variableElement, + sortText: "0" + }); + } } function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral): CompletionInfo { diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 44c2ede9fbb..9e4d906d300 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -260,7 +260,7 @@ namespace ts.SignatureHelp { * Returns relevant information for the argument list and the current argument if we are * in the argument of an invocation; returns undefined otherwise. */ - function getImmediatelyContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo { + export function getImmediatelyContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo { if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) { const callExpression = node.parent; // There are 3 cases to handle: diff --git a/tests/cases/fourslash/completionForStringLiteral6.ts b/tests/cases/fourslash/completionForStringLiteral6.ts new file mode 100644 index 00000000000..ac4a378abfb --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral6.ts @@ -0,0 +1,12 @@ +/// + +////interface Foo { +//// x: "abc" | "def"; +////} +////function bar(f: Foo) { }; +////bar({x: "/**/"}); + +goTo.marker(); +verify.completionListContains("abc"); +verify.completionListContains("def"); +verify.completionListCount(2); diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 9063d909b15..67bbce2a472 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -129,7 +129,7 @@ function dir(dirPath: string, spec?: string, options?: any) { function deleteFolderRecursive(dirPath: string) { if (fs.existsSync(dirPath)) { fs.readdirSync(dirPath).forEach((file) => { - const curPath = path.join(path, file); + const curPath = path.join(dirPath, file); if (fs.statSync(curPath).isDirectory()) { // recurse deleteFolderRecursive(curPath); } From 876dbe86ee17b8521f6535739a01fe489d768a26 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 9 Jan 2017 08:53:10 -0800 Subject: [PATCH 075/175] Omit class methods from spreads. Others stay. Previously, all methods were omitted except those from the object literal that contained the spread. This gets rid of the ugly third argument to `getSpreadType`. It also fixes a bug that arose from removing the spread type late in the development of object spread; methods from the left-hand-side of a multi-spread object literal were not removed. The spread type code normalised spreads so the left-hand is never an object, but that code was removed. --- src/compiler/checker.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 879be1c6fbf..d33ce374736 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6241,7 +6241,7 @@ namespace ts { * this function should be called in a left folding style, with left = previous result of getSpreadType * and right = the new element to be spread. */ - function getSpreadType(left: Type, right: Type, isFromObjectLiteral: boolean): Type { + function getSpreadType(left: Type, right: Type): Type { if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } @@ -6254,10 +6254,10 @@ namespace ts { return left; } if (left.flags & TypeFlags.Union) { - return mapType(left, t => getSpreadType(t, right, isFromObjectLiteral)); + return mapType(left, t => getSpreadType(t, right)); } if (right.flags & TypeFlags.Union) { - return mapType(right, t => getSpreadType(left, t, isFromObjectLiteral)); + return mapType(right, t => getSpreadType(left, t)); } const members = createMap(); @@ -6276,18 +6276,18 @@ namespace ts { for (const rightProp of getPropertiesOfType(right)) { // we approximate own properties as non-methods plus methods that are inside the object literal - const isOwnProperty = !(rightProp.flags & SymbolFlags.Method) || isFromObjectLiteral; const isSetterWithoutGetter = rightProp.flags & SymbolFlags.SetAccessor && !(rightProp.flags & SymbolFlags.GetAccessor); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) { skippedPrivateMembers[rightProp.name] = true; } - else if (isOwnProperty && !isSetterWithoutGetter) { + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { members[rightProp.name] = rightProp; } } for (const leftProp of getPropertiesOfType(left)) { if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor) - || leftProp.name in skippedPrivateMembers) { + || leftProp.name in skippedPrivateMembers + || isClassMethod(leftProp)) { continue; } if (leftProp.name in members) { @@ -6312,6 +6312,10 @@ namespace ts { return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop: Symbol) { + return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); + } + function createLiteralType(flags: TypeFlags, text: string) { const type = createType(flags); type.text = text; @@ -11658,7 +11662,7 @@ namespace ts { checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = createMap(); hasComputedStringProperty = false; @@ -11670,7 +11674,7 @@ namespace ts { error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } @@ -11715,7 +11719,7 @@ namespace ts { if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & TypeFlags.Object) { // only set the symbol and flags if this is a (fresh) object type From 309a361b19a1a8435f2c4f5f232d1716995ff171 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 9 Jan 2017 08:59:36 -0800 Subject: [PATCH 076/175] Test method removal of object spread Test that 1. Only class methods get removed 2. Methods from both left and right get removed. --- .../reference/spreadMethods.errors.txt | 33 ++++++++++ tests/baselines/reference/spreadMethods.js | 63 +++++++++++++++++++ .../conformance/types/spread/spreadMethods.ts | 23 +++++++ 3 files changed, 119 insertions(+) create mode 100644 tests/baselines/reference/spreadMethods.errors.txt create mode 100644 tests/baselines/reference/spreadMethods.js create mode 100644 tests/cases/conformance/types/spread/spreadMethods.ts diff --git a/tests/baselines/reference/spreadMethods.errors.txt b/tests/baselines/reference/spreadMethods.errors.txt new file mode 100644 index 00000000000..b2b3491ba79 --- /dev/null +++ b/tests/baselines/reference/spreadMethods.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/types/spread/spreadMethods.ts(7,4): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/spreadMethods.ts(9,5): error TS2339: Property 'm' does not exist on type '{ p: number; }'. + + +==== tests/cases/conformance/types/spread/spreadMethods.ts (2 errors) ==== + class K { p = 12; m() { } } + interface I { p: number, m(): void } + let k = new K() + let sk = { ...k }; + let ssk = { ...k, ...k }; + sk.p; + sk.m(); // error + ~ +!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'. + ssk.p; + ssk.m(); // error + ~ +!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'. + let i: I = { p: 12, m() { } }; + let si = { ...i }; + let ssi = { ...i, ...i }; + si.p; + si.m(); // ok + ssi.p; + ssi.m(); // ok + let o = { p: 12, m() { } }; + let so = { ...o }; + let sso = { ...o, ...o }; + so.p; + so.m(); // ok + sso.p; + sso.m(); // ok + \ No newline at end of file diff --git a/tests/baselines/reference/spreadMethods.js b/tests/baselines/reference/spreadMethods.js new file mode 100644 index 00000000000..691d6fa2829 --- /dev/null +++ b/tests/baselines/reference/spreadMethods.js @@ -0,0 +1,63 @@ +//// [spreadMethods.ts] +class K { p = 12; m() { } } +interface I { p: number, m(): void } +let k = new K() +let sk = { ...k }; +let ssk = { ...k, ...k }; +sk.p; +sk.m(); // error +ssk.p; +ssk.m(); // error +let i: I = { p: 12, m() { } }; +let si = { ...i }; +let ssi = { ...i, ...i }; +si.p; +si.m(); // ok +ssi.p; +ssi.m(); // ok +let o = { p: 12, m() { } }; +let so = { ...o }; +let sso = { ...o, ...o }; +so.p; +so.m(); // ok +sso.p; +sso.m(); // ok + + +//// [spreadMethods.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +var K = (function () { + function K() { + this.p = 12; + } + K.prototype.m = function () { }; + return K; +}()); +var k = new K(); +var sk = __assign({}, k); +var ssk = __assign({}, k, k); +sk.p; +sk.m(); // error +ssk.p; +ssk.m(); // error +var i = { p: 12, m: function () { } }; +var si = __assign({}, i); +var ssi = __assign({}, i, i); +si.p; +si.m(); // ok +ssi.p; +ssi.m(); // ok +var o = { p: 12, m: function () { } }; +var so = __assign({}, o); +var sso = __assign({}, o, o); +so.p; +so.m(); // ok +sso.p; +sso.m(); // ok diff --git a/tests/cases/conformance/types/spread/spreadMethods.ts b/tests/cases/conformance/types/spread/spreadMethods.ts new file mode 100644 index 00000000000..5d562653424 --- /dev/null +++ b/tests/cases/conformance/types/spread/spreadMethods.ts @@ -0,0 +1,23 @@ +class K { p = 12; m() { } } +interface I { p: number, m(): void } +let k = new K() +let sk = { ...k }; +let ssk = { ...k, ...k }; +sk.p; +sk.m(); // error +ssk.p; +ssk.m(); // error +let i: I = { p: 12, m() { } }; +let si = { ...i }; +let ssi = { ...i, ...i }; +si.p; +si.m(); // ok +ssi.p; +ssi.m(); // ok +let o = { p: 12, m() { } }; +let so = { ...o }; +let sso = { ...o, ...o }; +so.p; +so.m(); // ok +sso.p; +sso.m(); // ok From 9441555778452389b239970cef1f20675ae4ccbf Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 9 Jan 2017 09:11:09 -0800 Subject: [PATCH 077/175] Properly construct replacement mapper in mapped type instantiation --- 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 879be1c6fbf..5dbff583bcf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6564,6 +6564,12 @@ namespace ts { return mapper; } + function createReplacementMapper(source: Type, target: Type, baseMapper: TypeMapper) { + const mapper: TypeMapper = t => t === source ? target : baseMapper(t); + mapper.mappedTypes = baseMapper.mappedTypes; + return mapper; + } + function cloneTypeParameter(typeParameter: TypeParameter): TypeParameter { const result = createType(TypeFlags.TypeParameter); result.symbol = typeParameter.symbol; @@ -6662,10 +6668,7 @@ namespace ts { if (typeVariable !== mappedTypeVariable) { return mapType(mappedTypeVariable, t => { if (isMappableType(t)) { - const replacementMapper = createUnaryTypeMapper(typeVariable, t); - const combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable, t, mapper)); } return t; }); From 80ef89b822d4b11c5bce299250d76852b20cf540 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 9 Jan 2017 09:19:03 -0800 Subject: [PATCH 078/175] Add regression test --- ...ppedTypeWithCombinedTypeMappers.errors.txt | 25 +++++++++++++++++++ .../mappedTypeWithCombinedTypeMappers.js | 24 ++++++++++++++++++ .../mappedTypeWithCombinedTypeMappers.ts | 18 +++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt create mode 100644 tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js create mode 100644 tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts diff --git a/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt new file mode 100644 index 00000000000..56837dd787e --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts(18,7): error TS2322: Type 'string' is not assignable to type '{ important: boolean; }'. + + +==== tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts (1 errors) ==== + // Repro from #13351 + + type Meta = { + readonly[P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; + } + + interface Input { + x: string; + y: number; + } + + declare const output: Meta; + + const shouldFail: { important: boolean } = output.x.children; + ~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '{ important: boolean; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js new file mode 100644 index 00000000000..a445f2eebc5 --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js @@ -0,0 +1,24 @@ +//// [mappedTypeWithCombinedTypeMappers.ts] +// Repro from #13351 + +type Meta = { + readonly[P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; +} + +interface Input { + x: string; + y: number; +} + +declare const output: Meta; + +const shouldFail: { important: boolean } = output.x.children; + + +//// [mappedTypeWithCombinedTypeMappers.js] +// Repro from #13351 +var shouldFail = output.x.children; diff --git a/tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts b/tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts new file mode 100644 index 00000000000..9c6d8479b2e --- /dev/null +++ b/tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts @@ -0,0 +1,18 @@ +// Repro from #13351 + +type Meta = { + readonly[P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; +} + +interface Input { + x: string; + y: number; +} + +declare const output: Meta; + +const shouldFail: { important: boolean } = output.x.children; From 2124fcf5885c6498930862b0ad9b452319e617e5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 9 Jan 2017 09:40:03 -0800 Subject: [PATCH 079/175] goToDefinition: Use the name of a declaration (if possible) when creating DefinitionInfo. --- src/compiler/utilities.ts | 4 ++ src/harness/fourslash.ts | 54 ++++++++++++------- src/services/findAllReferences.ts | 6 +-- src/services/goToDefinition.ts | 45 ++++++++-------- src/services/navigateTo.ts | 2 +- src/services/navigationBar.ts | 12 ++--- src/services/outliningElementsCollector.ts | 4 +- .../ambientShorthandGotoDefinition.ts | 10 ++-- tests/cases/fourslash/fourslash.ts | 3 +- tests/cases/fourslash/goToDefinitionAlias.ts | 4 +- .../cases/fourslash/goToDefinitionAmbiants.ts | 6 +-- .../fourslash/goToDefinitionDecorator.ts | 4 +- ...ts => goToDefinitionDecoratorOverloads.ts} | 4 +- .../fourslash/goToDefinitionDifferentFile.ts | 8 +-- .../goToDefinitionDifferentFileIndirectly.ts | 8 +-- .../goToDefinitionExternalModuleName3.ts | 2 +- .../goToDefinitionExternalModuleName5.ts | 2 +- .../goToDefinitionExternalModuleName6.ts | 2 +- .../goToDefinitionExternalModuleName7.ts | 2 +- .../goToDefinitionExternalModuleName8.ts | 2 +- .../goToDefinitionExternalModuleName9.ts | 2 +- tests/cases/fourslash/goToDefinitionFoo.ts | 6 +++ .../goToDefinitionFunctionOverloads.ts | 8 +-- .../goToDefinitionFunctionOverloadsInClass.ts | 4 +- .../goToDefinitionImplicitConstructor.ts | 2 +- .../fourslash/goToDefinitionImportedNames.ts | 2 +- .../fourslash/goToDefinitionImportedNames2.ts | 2 +- .../fourslash/goToDefinitionImportedNames3.ts | 2 +- .../fourslash/goToDefinitionImportedNames4.ts | 2 +- .../fourslash/goToDefinitionImportedNames5.ts | 2 +- .../fourslash/goToDefinitionImportedNames7.ts | 2 +- .../goToDefinitionInMemberDeclaration.ts | 8 +-- .../fourslash/goToDefinitionInTypeArgument.ts | 4 +- .../goToDefinitionInterfaceAfterImplement.ts | 2 +- .../goToDefinitionMethodOverloads.ts | 16 +++--- .../goToDefinitionMultipleDefinitions.ts | 10 ++-- .../goToDefinitionObjectLiteralProperties.ts | 4 +- ...tionOverloadsInMultiplePropertyAccesses.ts | 2 +- .../goToDefinitionPartialImplementation.ts | 4 +- .../cases/fourslash/goToDefinitionSameFile.ts | 8 +-- tests/cases/fourslash/goToDefinitionSimple.ts | 2 +- .../goToDefinitionTaggedTemplateOverloads.ts | 4 +- tests/cases/fourslash/goToDefinitionThis.ts | 2 +- .../fourslash/goToDefinitionTypePredicate.ts | 2 +- tests/cases/fourslash/goToDefinition_super.ts | 2 +- .../fourslash/goToModuleAliasDefinition.ts | 4 +- tests/cases/fourslash/goToTypeDefinition.ts | 6 +-- tests/cases/fourslash/goToTypeDefinition2.ts | 6 +-- .../fourslash/goToTypeDefinitionAliases.ts | 13 ++--- .../goToTypeDefinitionEnumMembers.ts | 4 +- .../fourslash/goToTypeDefinitionModule.ts | 17 +++--- .../fourslash/goToTypeDefinitionPrimitives.ts | 17 +++--- .../fourslash/goToTypeDefinitionUnionType.ts | 18 ++----- tests/cases/fourslash/quickInfoMeaning.ts | 6 +-- .../server/jsdocTypedefTagGoToDefinition.ts | 2 +- .../fourslash/server/typedefinition01.ts | 6 +-- .../shims-pp/getDefinitionAtPosition.ts | 8 +-- .../fourslash/shims-pp/goToTypeDefinition.ts | 6 +-- .../shims/getDefinitionAtPosition.ts | 8 +-- .../fourslash/shims/goToTypeDefinition.ts | 6 +-- .../fourslash/tsxGoToDefinitionClasses.ts | 2 +- 61 files changed, 207 insertions(+), 210 deletions(-) rename tests/cases/fourslash/{goToDeclarationDecoratorOverloads.ts => goToDefinitionDecoratorOverloads.ts} (72%) create mode 100644 tests/cases/fourslash/goToDefinitionFoo.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 192ef888b11..6a017fd996d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4318,6 +4318,10 @@ namespace ts { return createTextSpan(start, end - start); } + export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { + return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + export function textChangeRangeNewSpan(range: TextChangeRange) { return createTextSpan(range.span.start, range.newLength); } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 3de0dba4fdf..c41c9af9f4e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -47,9 +47,9 @@ namespace FourSlash { /** * Inserted in source files by surrounding desired text * in a range with `[|` and `|]`. For example, - * + * * [|text in range|] - * + * * is a range with `text in range` "selected". */ ranges: Range[]; @@ -540,53 +540,66 @@ namespace FourSlash { } public verifyGoToDefinitionIs(endMarker: string | string[]) { - this.verifyGoToDefinitionWorker(endMarker instanceof Array ? endMarker : [endMarker]); + this.verifyGoToXWorker(endMarker instanceof Array ? endMarker : [endMarker], () => this.getGoToDefinition()); } public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) { + this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinition()); + } + + private getGoToDefinition(): ts.DefinitionInfo[] { + return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) + } + + public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) { + this.verifyGoToX(arg0, endMarkerNames, () => + this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)); + } + + private verifyGoToX(arg0: any, endMarkerNames: string | string[] | undefined, getDefs: () => ts.DefinitionInfo[] | undefined) { if (endMarkerNames) { - this.verifyGoToDefinitionPlain(arg0, endMarkerNames); + this.verifyGoToXPlain(arg0, endMarkerNames, getDefs); } else if (arg0 instanceof Array) { const pairs: [string | string[], string | string[]][] = arg0; for (const [start, end] of pairs) { - this.verifyGoToDefinitionPlain(start, end); + this.verifyGoToXPlain(start, end, getDefs); } } else { const obj: { [startMarkerName: string]: string | string[] } = arg0; for (const startMarkerName in obj) { if (ts.hasProperty(obj, startMarkerName)) { - this.verifyGoToDefinitionPlain(startMarkerName, obj[startMarkerName]); + this.verifyGoToXPlain(startMarkerName, obj[startMarkerName], getDefs); } } } } - private verifyGoToDefinitionPlain(startMarkerNames: string | string[], endMarkerNames: string | string[]) { + private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { if (startMarkerNames instanceof Array) { for (const start of startMarkerNames) { - this.verifyGoToDefinitionSingle(start, endMarkerNames); + this.verifyGoToXSingle(start, endMarkerNames, getDefs); } } else { - this.verifyGoToDefinitionSingle(startMarkerNames, endMarkerNames); + this.verifyGoToXSingle(startMarkerNames, endMarkerNames, getDefs); } } public verifyGoToDefinitionForMarkers(markerNames: string[]) { for (const markerName of markerNames) { - this.verifyGoToDefinitionSingle(`${markerName}Reference`, `${markerName}Definition`); + this.verifyGoToXSingle(`${markerName}Reference`, `${markerName}Definition`, () => this.getGoToDefinition()); } } - private verifyGoToDefinitionSingle(startMarkerName: string, endMarkerNames: string | string[]) { + private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { this.goToMarker(startMarkerName); - this.verifyGoToDefinitionWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames]); + this.verifyGoToXWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames], getDefs); } - private verifyGoToDefinitionWorker(endMarkers: string[]) { - const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) || []; + private verifyGoToXWorker(endMarkers: string[], getDefs: () => ts.DefinitionInfo[] | undefined) { + const definitions = getDefs() || []; if (endMarkers.length !== definitions.length) { this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`); @@ -1987,7 +2000,7 @@ namespace FourSlash { * Compares expected text to the text that would be in the sole range * (ie: [|...|]) in the file after applying the codefix sole codefix * in the source file. - * + * * Because codefixes are only applied on the working file, it is unsafe * to apply this more than once (consider a refactoring across files). */ @@ -3042,10 +3055,6 @@ namespace FourSlashInterface { this.state.goToEOF(); } - public type(definitionIndex = 0) { - this.state.goToTypeDefinition(definitionIndex); - } - public implementation() { this.state.goToImplementation(); } @@ -3213,6 +3222,13 @@ namespace FourSlashInterface { this.state.verifyGoToDefinition(arg0, endMarkerName); } + public goToType(startMarkerName: string | string[], endMarkerName: string | string[]): void; + public goToType(startsAndEnds: [string | string[], string | string[]][]): void; + public goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; + public goToType(arg0: any, endMarkerName?: string | string[]) { + this.state.verifyGoToType(arg0, endMarkerName); + } + public goToDefinitionForMarkers(...markerNames: string[]) { this.state.verifyGoToDefinitionForMarkers(markerNames); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 313a3d2ea3e..d6092644c73 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -325,7 +325,7 @@ namespace ts.FindAllReferences { fileName: targetLabel.getSourceFile().fileName, kind: ScriptElementKind.label, name: labelName, - textSpan: createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), + textSpan: createTextSpanFromNode(targetLabel, sourceFile), displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)] }; @@ -871,7 +871,7 @@ namespace ts.FindAllReferences { fileName: node.getSourceFile().fileName, kind: ScriptElementKind.variableElement, name: "this", - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), + textSpan: createTextSpanFromNode(node), displayParts }, references: references @@ -942,7 +942,7 @@ namespace ts.FindAllReferences { fileName: node.getSourceFile().fileName, kind: ScriptElementKind.variableElement, name: type.text, - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), + textSpan: createTextSpanFromNode(node), displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] }, references: references diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 4c005640d6a..65421888061 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -15,10 +15,8 @@ namespace ts.GoToDefinition { const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { const referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } const node = getTouchingPropertyName(sourceFile, position); @@ -30,7 +28,7 @@ namespace ts.GoToDefinition { if (isJumpStatementTarget(node)) { const labelName = (node).text; const label = getTargetLabel((node.parent), (node).text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } const typeChecker = program.getTypeChecker(); @@ -171,33 +169,38 @@ namespace ts.GoToDefinition { function tryAddSignature(signatureDeclarations: Declaration[], selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { const declarations: Declaration[] = []; - let definition: Declaration; + let definition: Declaration | undefined; - forEach(signatureDeclarations, d => { - if ((selectConstructors && d.kind === SyntaxKind.Constructor) || - (!selectConstructors && (d.kind === SyntaxKind.FunctionDeclaration || d.kind === SyntaxKind.MethodDeclaration || d.kind === SyntaxKind.MethodSignature))) { + for (const d of signatureDeclarations) { + if (selectConstructors ? d.kind === SyntaxKind.Constructor : isSignatureDeclaration(d)) { declarations.push(d); if ((d).body) definition = d; } - }); - - if (definition) { - result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); - return true; - } - else if (declarations.length) { - result.push(createDefinitionInfo(lastOrUndefined(declarations), symbolKind, symbolName, containerName)); - return true; } + if (declarations.length) { + result.push(createDefinitionInfo(definition || lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } return false; } } - function createDefinitionInfo(node: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + function isSignatureDeclaration(node: Node): boolean { + return node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature + } + + /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ + function createDefinitionInfo(node: Declaration, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + + /** Creates a DefinitionInfo directly from the name of a declaration. */ + function createDefinitionInfoFromName(name: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + const sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 82f4dd49f2b..7dab7b504cd 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -199,7 +199,7 @@ namespace ts.NavigateTo { matchKind: PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: container && container.name ? (container.name).text : "", containerKind: container && container.name ? getNodeKind(container) : "" diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 4e5986abc01..28f69a0b488 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -591,7 +591,7 @@ namespace ts.NavigationBar { function getNodeSpan(node: Node): TextSpan { return node.kind === SyntaxKind.SourceFile ? createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : createTextSpanFromNode(node, curSourceFile); } function getFunctionOrClassName(node: FunctionExpression | FunctionDeclaration | ArrowFunction | ClassLikeDeclaration): string { @@ -626,15 +626,15 @@ namespace ts.NavigationBar { /** * Matches all whitespace characters in a string. Eg: - * + * * "app. - * + * * onactivated" - * + * * matches because of the newline, whereas - * + * * "app.onactivated" - * + * * does not match. */ const whiteSpaceRegex = /\s+/g; diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index dc2e4a59773..2ad20a7ed0c 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -8,7 +8,7 @@ namespace ts.OutliningElementsCollector { if (hintSpanNode && startElement && endElement) { const span: OutliningSpan = { textSpan: createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -135,7 +135,7 @@ namespace ts.OutliningElementsCollector { // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - const span = createTextSpanFromBounds(n.getStart(), n.end); + const span = createTextSpanFromNode(n); elements.push({ textSpan: span, hintSpan: span, diff --git a/tests/cases/fourslash/ambientShorthandGotoDefinition.ts b/tests/cases/fourslash/ambientShorthandGotoDefinition.ts index 8673d661fe2..410fc932cec 100644 --- a/tests/cases/fourslash/ambientShorthandGotoDefinition.ts +++ b/tests/cases/fourslash/ambientShorthandGotoDefinition.ts @@ -1,13 +1,13 @@ /// // @Filename: declarations.d.ts -/////*module*/declare module "jquery" +////declare module /*module*/"jquery" // @Filename: user.ts /////// ////import /*importFoo*/foo, {bar} from "jquery"; -////import /*importBaz*/* as /*idBaz*/baz from "jquery"; -/////*importBang*/import /*idBang*/bang = require("jquery"); +////import * as /*importBaz*/baz from "jquery"; +////import /*importBang*/bang = require("jquery"); ////foo/*useFoo*/(bar/*useBar*/, baz/*useBaz*/, bang/*useBang*/); verify.quickInfoAt("useFoo", "import foo"); @@ -22,11 +22,11 @@ verify.goToDefinition("useBar", "module"); verify.quickInfoAt("useBaz", "import baz"); verify.goToDefinition({ useBaz: "importBaz", - idBaz: "module" + importBaz: "module" }); verify.quickInfoAt("useBang", "import bang = require(\"jquery\")"); verify.goToDefinition({ useBang: "importBang", - idBang: "module" + importBang: "module" }); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index b8017134db8..4397839fbe8 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -110,7 +110,6 @@ declare namespace FourSlashInterface { marker(name?: string): void; bof(): void; eof(): void; - type(definitionIndex?: number): void; implementation(): void; position(position: number, fileIndex?: number): any; position(position: number, fileName?: string): any; @@ -165,6 +164,8 @@ declare namespace FourSlashInterface { goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; /** Verifies goToDefinition for each `${markerName}Reference` -> `${markerName}Definition` */ goToDefinitionForMarkers(...markerNames: string[]): void; + goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; + goToType(startMarkerNames: string | string[], endMarkerNames: string | string[]): void; verifyGetEmitOutputForCurrentFile(expected: string): void; verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void; /** diff --git a/tests/cases/fourslash/goToDefinitionAlias.ts b/tests/cases/fourslash/goToDefinitionAlias.ts index 23cf849f101..22aa049fde3 100644 --- a/tests/cases/fourslash/goToDefinitionAlias.ts +++ b/tests/cases/fourslash/goToDefinitionAlias.ts @@ -1,9 +1,9 @@ /// // @Filename: b.ts -/////*alias1Definition*/import alias1 = require("fileb"); +////import /*alias1Definition*/alias1 = require("fileb"); ////module Module { -//// /*alias2Definition*/export import alias2 = alias1; +//// export import /*alias2Definition*/alias2 = alias1; ////} //// ////// Type position diff --git a/tests/cases/fourslash/goToDefinitionAmbiants.ts b/tests/cases/fourslash/goToDefinitionAmbiants.ts index 57885bed4e9..b0932f0cb07 100644 --- a/tests/cases/fourslash/goToDefinitionAmbiants.ts +++ b/tests/cases/fourslash/goToDefinitionAmbiants.ts @@ -1,11 +1,11 @@ /// ////declare var /*ambientVariableDefinition*/ambientVar; -/////*ambientFunctionDefinition*/declare function ambientFunction(); +////declare function /*ambientFunctionDefinition*/ambientFunction(); ////declare class ambientClass { //// /*constructorDefinition*/constructor(); -//// /*staticMethodDefinition*/static method(); -//// /*instanceMethodDefinition*/public method(); +//// static /*staticMethodDefinition*/method(); +//// public /*instanceMethodDefinition*/method(); ////} //// /////*ambientVariableReference*/ambientVar = 1; diff --git a/tests/cases/fourslash/goToDefinitionDecorator.ts b/tests/cases/fourslash/goToDefinitionDecorator.ts index c86b02ab820..bef9c8fa5f1 100644 --- a/tests/cases/fourslash/goToDefinitionDecorator.ts +++ b/tests/cases/fourslash/goToDefinitionDecorator.ts @@ -9,10 +9,10 @@ // @Filename: a.ts -/////*decoratorDefinition*/function decorator(target) { +////function /*decoratorDefinition*/decorator(target) { //// return target; ////} -/////*decoratorFactoryDefinition*/function decoratorFactory(...args) { +////function /*decoratorFactoryDefinition*/decoratorFactory(...args) { //// return target => target; ////} diff --git a/tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts b/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts similarity index 72% rename from tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts rename to tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts index c107f7f6803..965c8bbbc6d 100644 --- a/tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts @@ -3,8 +3,8 @@ ////async function f() {} //// -/////*defDecString*/function dec(target: any, propertyKey: string): void; -/////*defDecSymbol*/function dec(target: any, propertyKey: symbol): void; +////function /*defDecString*/dec(target: any, propertyKey: string): void; +////function /*defDecSymbol*/dec(target: any, propertyKey: symbol): void; ////function dec(target: any, propertyKey: string | symbol) {} //// ////declare const s: symbol; diff --git a/tests/cases/fourslash/goToDefinitionDifferentFile.ts b/tests/cases/fourslash/goToDefinitionDifferentFile.ts index 1679563942c..67e8c44c84c 100644 --- a/tests/cases/fourslash/goToDefinitionDifferentFile.ts +++ b/tests/cases/fourslash/goToDefinitionDifferentFile.ts @@ -2,10 +2,10 @@ // @Filename: goToDefinitionDifferentFile_Definition.ts ////var /*remoteVariableDefinition*/remoteVariable; -/////*remoteFunctionDefinition*/function remoteFunction() { } -/////*remoteClassDefinition*/class remoteClass { } -/////*remoteInterfaceDefinition*/interface remoteInterface{ } -/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} +////function /*remoteFunctionDefinition*/remoteFunction() { } +////class /*remoteClassDefinition*/remoteClass { } +////interface /*remoteInterfaceDefinition*/remoteInterface{ } +////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;} // @Filename: goToDefinitionDifferentFile_Consumption.ts /////*remoteVariableReference*/remoteVariable = 1; diff --git a/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts b/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts index 96a65a22033..f577712c930 100644 --- a/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts +++ b/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts @@ -2,10 +2,10 @@ // @Filename: Remote2.ts ////var /*remoteVariableDefinition*/rem2Var; -/////*remoteFunctionDefinition*/function rem2Fn() { } -/////*remoteClassDefinition*/class rem2Cls { } -/////*remoteInterfaceDefinition*/interface rem2Int{} -/////*remoteModuleDefinition*/module rem2Mod { export var foo; } +////function /*remoteFunctionDefinition*/rem2Fn() { } +////class /*remoteClassDefinition*/rem2Cls { } +////interface /*remoteInterfaceDefinition*/rem2Int{} +////module /*remoteModuleDefinition*/rem2Mod { export var foo; } // @Filename: Remote1.ts ////var remVar; diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts index afd3b4054a2..7ac0376474d 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName3.ts @@ -5,7 +5,7 @@ ////var x = new n.Foo(); // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts index ae9343a8f5b..36ae9dd716f 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts @@ -1,7 +1,7 @@ /// // @Filename: a.ts -/////*2*/declare module "external/*1*/" { +////declare module /*2*/"external/*1*/" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts index 03c3a23febc..a71030628e6 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts @@ -4,7 +4,7 @@ ////import * from 'e/*1*/'; // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts index 4c82099ab20..b025944d012 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName7.ts @@ -4,7 +4,7 @@ ////import {Foo, Bar} from 'e/*1*/'; // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts index 5eab37e8393..ca9d7c83e66 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts @@ -4,7 +4,7 @@ ////export {Foo, Bar} from 'e/*1*/'; // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts b/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts index 9e0c1b4986e..80971be100f 100644 --- a/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts +++ b/tests/cases/fourslash/goToDefinitionExternalModuleName9.ts @@ -4,7 +4,7 @@ ////export * from 'e/*1*/'; // @Filename: a.ts -/////*2*/declare module "e" { +////declare module /*2*/"e" { //// class Foo { } ////} diff --git a/tests/cases/fourslash/goToDefinitionFoo.ts b/tests/cases/fourslash/goToDefinitionFoo.ts new file mode 100644 index 00000000000..3e05ee20ecb --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionFoo.ts @@ -0,0 +1,6 @@ +/// + +////function /*def*/f() {} +/////*use*/f(123); + +verify.goToDefinition("use", "def"); diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts index e30150a1f45..60c7a8111ee 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts @@ -1,8 +1,8 @@ /// -/////*functionOverload1*/function /*functionOverload*/functionOverload(value: number); -/////*functionOverload2*/function functionOverload(value: string); -/////*functionOverloadDefinition*/function functionOverload() {} +////function /*functionOverload1*/functionOverload(value: number); +////function /*functionOverload2*/functionOverload(value: string); +////function /*functionOverloadDefinition*/functionOverload() {} //// /////*functionOverloadReference1*/functionOverload(123); /////*functionOverloadReference2*/functionOverload("123"); @@ -12,5 +12,5 @@ verify.goToDefinition({ functionOverloadReference1: "functionOverload1", functionOverloadReference2: "functionOverload2", brokenOverload: "functionOverload1", - functionOverload: "functionOverloadDefinition" + functionOverload1: "functionOverloadDefinition" }); diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts index 3426a4d5e1e..04017123fd8 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts @@ -3,10 +3,10 @@ ////class clsInOverload { //// static fnOverload(); //// static /*staticFunctionOverload*/fnOverload(foo: string); -//// /*staticFunctionOverloadDefinition*/static fnOverload(foo: any) { } +//// static /*staticFunctionOverloadDefinition*/fnOverload(foo: any) { } //// public /*functionOverload*/fnOverload(): any; //// public fnOverload(foo: string); -//// /*functionOverloadDefinition*/public fnOverload(foo: any) { return "foo" } +//// public /*functionOverloadDefinition*/fnOverload(foo: any) { return "foo" } //// //// constructor() { } ////} diff --git a/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts b/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts index bf24e35307f..2d1dde785a7 100644 --- a/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts +++ b/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts @@ -1,6 +1,6 @@ /// -/////*constructorDefinition*/class ImplicitConstructor { +////class /*constructorDefinition*/ImplicitConstructor { ////} ////var implicitConstructor = new /*constructorReference*/ImplicitConstructor(); diff --git a/tests/cases/fourslash/goToDefinitionImportedNames.ts b/tests/cases/fourslash/goToDefinitionImportedNames.ts index b7374d00f18..41a1c443b28 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames.ts @@ -7,7 +7,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames2.ts b/tests/cases/fourslash/goToDefinitionImportedNames2.ts index b0b8776ee37..fa3c5c862b7 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames2.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames2.ts @@ -7,7 +7,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames3.ts b/tests/cases/fourslash/goToDefinitionImportedNames3.ts index f8016464360..b9f598f30cd 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames3.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames3.ts @@ -20,7 +20,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames4.ts b/tests/cases/fourslash/goToDefinitionImportedNames4.ts index 4b6b019cfae..81f2e671266 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames4.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames4.ts @@ -7,7 +7,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames5.ts b/tests/cases/fourslash/goToDefinitionImportedNames5.ts index 5add12ae0bc..b78110c95d9 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames5.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames5.ts @@ -7,7 +7,7 @@ // @Filename: a.ts ////export module Module { ////} -/////*classDefinition*/export class Class { +////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { diff --git a/tests/cases/fourslash/goToDefinitionImportedNames7.ts b/tests/cases/fourslash/goToDefinitionImportedNames7.ts index 86be4af3d85..bdf1eff86eb 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames7.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames7.ts @@ -5,7 +5,7 @@ // @Filename: a.ts -/////*classDefinition*/class Class { +////class /*classDefinition*/Class { //// private f; ////} ////export default Class; diff --git a/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts b/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts index 66719bb621b..93be2086440 100644 --- a/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts +++ b/tests/cases/fourslash/goToDefinitionInMemberDeclaration.ts @@ -1,14 +1,14 @@ /// -/////*interfaceDefinition*/interface IFoo { method1(): number; } +////interface /*interfaceDefinition*/IFoo { method1(): number; } //// -/////*classDefinition*/class Foo implements IFoo { +////class /*classDefinition*/Foo implements IFoo { //// public method1(): number { return 0; } ////} //// -/////*enumDefinition*/enum Enum { value1, value2 }; +////enum /*enumDefinition*/Enum { value1, value2 }; //// -/////*selfDefinition*/class Bar { +////class /*selfDefinition*/Bar { //// public _interface: IFo/*interfaceReference*/o = new Fo/*classReferenceInInitializer*/o(); //// public _class: Fo/*classReference*/o = new Foo(); //// public _list: IF/*interfaceReferenceInList*/oo[]=[]; diff --git a/tests/cases/fourslash/goToDefinitionInTypeArgument.ts b/tests/cases/fourslash/goToDefinitionInTypeArgument.ts index 343b5810df3..a9bddeda434 100644 --- a/tests/cases/fourslash/goToDefinitionInTypeArgument.ts +++ b/tests/cases/fourslash/goToDefinitionInTypeArgument.ts @@ -1,8 +1,8 @@ /// -/////*fooDefinition*/class Foo { } +////class /*fooDefinition*/Foo { } //// -/////*barDefinition*/class Bar { } +////class /*barDefinition*/Bar { } //// ////var x = new Fo/*fooReference*/o(); diff --git a/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts b/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts index 585cc187e48..46d9e0182a4 100644 --- a/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts +++ b/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts @@ -1,6 +1,6 @@ /// -/////*interfaceDefinition*/interface sInt { +////interface /*interfaceDefinition*/sInt { //// sVar: number; //// sFn: () => void; ////} diff --git a/tests/cases/fourslash/goToDefinitionMethodOverloads.ts b/tests/cases/fourslash/goToDefinitionMethodOverloads.ts index 199b5aee226..4dfe4753ce7 100644 --- a/tests/cases/fourslash/goToDefinitionMethodOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionMethodOverloads.ts @@ -1,12 +1,12 @@ /// ////class MethodOverload { -//// /*staticMethodOverload1*/static /*staticMethodOverload1Name*/method(); -//// /*staticMethodOverload2*/static method(foo: string); -//// /*staticMethodDefinition*/static method(foo?: any) { } -//// /*instanceMethodOverload1*/public /*instanceMethodOverload1Name*/method(): any; -//// /*instanceMethodOverload2*/public method(foo: string); -/////*instanceMethodDefinition*/public method(foo?: any) { return "foo" } +//// static /*staticMethodOverload1*/method(); +//// static /*staticMethodOverload2*/method(foo: string); +//// static /*staticMethodDefinition*/method(foo?: any) { } +//// public /*instanceMethodOverload1*/method(): any; +//// public /*instanceMethodOverload2*/method(foo: string); +//// public /*instanceMethodDefinition*/method(foo?: any) { return "foo" } ////} ////// static method @@ -23,6 +23,6 @@ verify.goToDefinition({ staticMethodReference2: "staticMethodOverload2", instanceMethodReference1: "instanceMethodOverload1", instanceMethodReference2: "instanceMethodOverload2", - staticMethodOverload1Name: "staticMethodDefinition", - instanceMethodOverload1Name: "instanceMethodDefinition" + staticMethodOverload1: "staticMethodDefinition", + instanceMethodOverload1: "instanceMethodDefinition" }); diff --git a/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts b/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts index 7b2cf6e7a85..fb022f7711f 100644 --- a/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts +++ b/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts @@ -1,16 +1,16 @@ /// // @Filename: a.ts -/////*interfaceDefinition1*/interface IFoo { +////interface /*interfaceDefinition1*/IFoo { //// instance1: number; ////} // @Filename: b.ts -/////*interfaceDefinition2*/interface IFoo { +////interface /*interfaceDefinition2*/IFoo { //// instance2: number; ////} //// -/////*interfaceDefinition3*/interface IFoo { +////interface /*interfaceDefinition3*/IFoo { //// instance3: number; ////} //// @@ -19,12 +19,12 @@ verify.goToDefinition("interfaceReference", ["interfaceDefinition1", "interfaceDefinition2", "interfaceDefinition3"]); // @Filename: c.ts -/////*moduleDefinition1*/module Module { +////module /*moduleDefinition1*/Module { //// export class c1 { } ////} // @Filename: d.ts -/////*moduleDefinition2*/module Module { +////module /*moduleDefinition2*/Module { //// export class c2 { } ////} diff --git a/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts b/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts index 8523df2111b..d430df3433d 100644 --- a/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts +++ b/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts @@ -2,8 +2,8 @@ ////var o = { //// /*valueDefinition*/value: 0, -//// /*getterDefinition*/get getter() {return 0 }, -//// /*setterDefinition*/set setter(v: number) { }, +//// get /*getterDefinition*/getter() {return 0 }, +//// set /*setterDefinition*/setter(v: number) { }, //// /*methodDefinition*/method: () => { }, //// /*es6StyleMethodDefinition*/es6StyleMethod() { } ////}; diff --git a/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts b/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts index 63c23cfe46f..04a07f41a7f 100644 --- a/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts +++ b/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts @@ -5,7 +5,7 @@ ////namespace A { //// export namespace B { //// export function f(value: number): void; -//// /*1*/export function f(value: string): void; +//// export function /*1*/f(value: string): void; //// export function f(value: number | string) {} //// } ////} diff --git a/tests/cases/fourslash/goToDefinitionPartialImplementation.ts b/tests/cases/fourslash/goToDefinitionPartialImplementation.ts index 90402b3f8e6..81f19b578ed 100644 --- a/tests/cases/fourslash/goToDefinitionPartialImplementation.ts +++ b/tests/cases/fourslash/goToDefinitionPartialImplementation.ts @@ -2,14 +2,14 @@ // @Filename: goToDefinitionPartialImplementation_1.ts ////module A { -//// /*Part1Definition*/export interface IA { +//// export interface /*Part1Definition*/IA { //// y: string; //// } ////} // @Filename: goToDefinitionPartialImplementation_2.ts ////module A { -//// /*Part2Definition*/export interface IA { +//// export interface /*Part2Definition*/IA { //// x: number; //// } //// diff --git a/tests/cases/fourslash/goToDefinitionSameFile.ts b/tests/cases/fourslash/goToDefinitionSameFile.ts index 6bbdaf3a189..e9b8b211bf7 100644 --- a/tests/cases/fourslash/goToDefinitionSameFile.ts +++ b/tests/cases/fourslash/goToDefinitionSameFile.ts @@ -1,10 +1,10 @@ /// ////var /*localVariableDefinition*/localVariable; -/////*localFunctionDefinition*/function localFunction() { } -/////*localClassDefinition*/class localClass { } -/////*localInterfaceDefinition*/interface localInterface{ } -/////*localModuleDefinition*/module localModule{ export var foo = 1;} +////function /*localFunctionDefinition*/localFunction() { } +////class /*localClassDefinition*/localClass { } +////interface /*localInterfaceDefinition*/localInterface{ } +////module /*localModuleDefinition*/localModule{ export var foo = 1;} //// //// /////*localVariableReference*/localVariable = 1; diff --git a/tests/cases/fourslash/goToDefinitionSimple.ts b/tests/cases/fourslash/goToDefinitionSimple.ts index 39aa8ecfca9..9ae02f26bf2 100644 --- a/tests/cases/fourslash/goToDefinitionSimple.ts +++ b/tests/cases/fourslash/goToDefinitionSimple.ts @@ -1,7 +1,7 @@ /// // @Filename: Definition.ts -//// /*2*/class c { } +////class /*2*/c { } // @Filename: Consumption.ts //// var n = new /*1*/c(); diff --git a/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts b/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts index fad27cabbb6..b01bace4feb 100644 --- a/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts @@ -1,7 +1,7 @@ /// -/////*defFNumber*/function f(strs: TemplateStringsArray, x: number): void; -/////*defFBool*/function f(strs: TemplateStringsArray, x: boolean): void; +////function /*defFNumber*/f(strs: TemplateStringsArray, x: number): void; +////function /*defFBool*/f(strs: TemplateStringsArray, x: boolean): void; ////function f(strs: TemplateStringsArray, x: number | boolean) {} //// /////*useFNumber*/f`${0}`; diff --git a/tests/cases/fourslash/goToDefinitionThis.ts b/tests/cases/fourslash/goToDefinitionThis.ts index 5cb94ef35c7..923fb6c8feb 100644 --- a/tests/cases/fourslash/goToDefinitionThis.ts +++ b/tests/cases/fourslash/goToDefinitionThis.ts @@ -3,7 +3,7 @@ ////function f(/*fnDecl*/this: number) { //// return /*fnUse*/this; ////} -/////*cls*/class C { +////class /*cls*/C { //// constructor() { return /*clsUse*/this; } //// get self(/*getterDecl*/this: number) { return /*getterUse*/this; } ////} diff --git a/tests/cases/fourslash/goToDefinitionTypePredicate.ts b/tests/cases/fourslash/goToDefinitionTypePredicate.ts index dd2b69f37e8..17e6fc1be6b 100644 --- a/tests/cases/fourslash/goToDefinitionTypePredicate.ts +++ b/tests/cases/fourslash/goToDefinitionTypePredicate.ts @@ -1,6 +1,6 @@ /// -//// /*classDeclaration*/class A {} +//// class /*classDeclaration*/A {} //// function f(/*parameterDeclaration*/parameter: any): /*parameterName*/parameter is /*typeReference*/A { //// return typeof parameter === "string"; //// } diff --git a/tests/cases/fourslash/goToDefinition_super.ts b/tests/cases/fourslash/goToDefinition_super.ts index 7a7008ba07f..115e4a4a6ed 100644 --- a/tests/cases/fourslash/goToDefinition_super.ts +++ b/tests/cases/fourslash/goToDefinition_super.ts @@ -4,7 +4,7 @@ //// /*ctr*/constructor() {} //// x() {} ////} -/////*B*/class B extends A {} +////class /*B*/B extends A {} ////class C extends B { //// constructor() { //// /*super*/super(); diff --git a/tests/cases/fourslash/goToModuleAliasDefinition.ts b/tests/cases/fourslash/goToModuleAliasDefinition.ts index cdec82fd0d4..dfccc3393c5 100644 --- a/tests/cases/fourslash/goToModuleAliasDefinition.ts +++ b/tests/cases/fourslash/goToModuleAliasDefinition.ts @@ -1,10 +1,10 @@ /// // @Filename: a.ts -//// /*2*/export class Foo {} +////export class /*2*/Foo {} // @Filename: b.ts -//// /*3*/import n = require('a'); +//// import /*3*/n = require('a'); //// var x = new /*1*/n.Foo(); // Won't-fixed: Should go to '2' instead diff --git a/tests/cases/fourslash/goToTypeDefinition.ts b/tests/cases/fourslash/goToTypeDefinition.ts index 6b34e7e4886..b6bbd839003 100644 --- a/tests/cases/fourslash/goToTypeDefinition.ts +++ b/tests/cases/fourslash/goToTypeDefinition.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinition_Definition.ts -/////*definition*/class C { +////class /*definition*/C { //// p; ////} ////var c: C; @@ -9,6 +9,4 @@ // @Filename: goToTypeDefinition_Consumption.ts /////*reference*/c = undefined; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/goToTypeDefinition2.ts b/tests/cases/fourslash/goToTypeDefinition2.ts index 8c76655f4a8..4f93edcd68a 100644 --- a/tests/cases/fourslash/goToTypeDefinition2.ts +++ b/tests/cases/fourslash/goToTypeDefinition2.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinition2_Definition.ts -/////*definition*/interface I1 { +////interface /*definition*/I1 { //// p; ////} ////type propertyType = I1; @@ -13,6 +13,4 @@ ////var i2: I2; ////i2.prop/*reference*/erty; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/goToTypeDefinitionAliases.ts b/tests/cases/fourslash/goToTypeDefinitionAliases.ts index da9d3d5a84e..89dacedc7aa 100644 --- a/tests/cases/fourslash/goToTypeDefinitionAliases.ts +++ b/tests/cases/fourslash/goToTypeDefinitionAliases.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinitioAliases_module1.ts -/////*definition*/interface I { +////interface /*definition*/I { //// p; ////} ////export {I as I2}; @@ -15,10 +15,7 @@ ////import {/*reference1*/v2 as v3} from "./goToTypeDefinitioAliases_module2"; /////*reference2*/v3; -goTo.marker('reference1'); -goTo.type(); -verify.caretAtMarker('definition'); - -goTo.marker('reference2'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType({ + reference1: "definition", + reference2: "definition" +}); diff --git a/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts b/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts index 1c2a0259d58..d4f89d29ee8 100644 --- a/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts +++ b/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts @@ -8,6 +8,4 @@ //// /////*reference*/x; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/goToTypeDefinitionModule.ts b/tests/cases/fourslash/goToTypeDefinitionModule.ts index 2afccab97c3..00e0fa82a09 100644 --- a/tests/cases/fourslash/goToTypeDefinitionModule.ts +++ b/tests/cases/fourslash/goToTypeDefinitionModule.ts @@ -1,19 +1,16 @@ /// -// @Filename: goToTypeDefinitioAliases_module1.ts -/////*definition*/module M { +// @Filename: module1.ts +////module /*definition*/M { //// export var p; ////} ////var m: typeof M; -// @Filename: goToTypeDefinitioAliases_module3.ts +// @Filename: module3.ts /////*reference1*/M; /////*reference2*/m; -goTo.marker('reference1'); -goTo.type(); -verify.caretAtMarker('definition'); - -goTo.marker('reference2'); -goTo.type(); -verify.caretAtMarker('definition'); \ No newline at end of file +verify.goToType({ + reference1: "definition", + reference2: "definition" +}); diff --git a/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts b/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts index d38a0c16343..0b6f6903524 100644 --- a/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts +++ b/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts @@ -12,14 +12,9 @@ /////*reference3*/y; /////*reference4*/y; -goTo.marker('reference1'); -verify.typeDefinitionCountIs(0); - -goTo.marker('reference1'); -verify.typeDefinitionCountIs(0); - -goTo.marker('reference2'); -verify.typeDefinitionCountIs(0); - -goTo.marker('reference4'); -verify.typeDefinitionCountIs(0); +verify.goToType({ + reference1: [], + reference2: [], + reference3: [], + reference4: [] +}); diff --git a/tests/cases/fourslash/goToTypeDefinitionUnionType.ts b/tests/cases/fourslash/goToTypeDefinitionUnionType.ts index 0630ae3ebb9..5658ce77b64 100644 --- a/tests/cases/fourslash/goToTypeDefinitionUnionType.ts +++ b/tests/cases/fourslash/goToTypeDefinitionUnionType.ts @@ -1,15 +1,15 @@ /// -/////*definition0*/class C { +////class /*definition0*/C { //// p; ////} //// -/////*definition1*/interface I { +////interface /*definition1*/I { //// x; ////} //// ////module M { -//// /*definition2*/export interface I { +//// export interface /*definition2*/I { //// y; //// } ////} @@ -18,14 +18,4 @@ //// /////*reference*/x; -goTo.marker('reference'); -goTo.type(0); -verify.caretAtMarker('definition0'); - -goTo.marker('reference'); -goTo.type(1); -verify.caretAtMarker('definition1'); - -goTo.marker('reference'); -goTo.type(2); -verify.caretAtMarker('definition2'); +verify.goToType("reference", ["definition0", "definition1", "definition2"]); diff --git a/tests/cases/fourslash/quickInfoMeaning.ts b/tests/cases/fourslash/quickInfoMeaning.ts index 390dc367959..414fcc0c86d 100644 --- a/tests/cases/fourslash/quickInfoMeaning.ts +++ b/tests/cases/fourslash/quickInfoMeaning.ts @@ -14,7 +14,7 @@ // @Filename: foo_user.ts /////// -/////*foo_type_declaration*/import foo = require("foo_module"); +////import /*foo_type_declaration*/foo = require("foo_module"); ////const x = foo/*foo_value*/; ////const i: foo/*foo_type*/ = { x: 1, y: 2 }; @@ -37,7 +37,7 @@ verify.goToDefinitionIs("foo_type_declaration"); // @Filename: bar.d.ts -/////*bar_type_declaration*/declare interface bar { x: number; y: number } +////declare interface /*bar_type_declaration*/bar { x: number; y: number } ////declare module "bar_module" { //// const x: number; //// export = x; @@ -45,7 +45,7 @@ verify.goToDefinitionIs("foo_type_declaration"); // @Filename: bar_user.ts /////// -/////*bar_value_declaration*/import bar = require("bar_module"); +////import /*bar_value_declaration*/bar = require("bar_module"); ////const x = bar/*bar_value*/; ////const i: bar/*bar_type*/ = { x: 1, y: 2 }; diff --git a/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts b/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts index 2183c8d5471..000adef9081 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagGoToDefinition.ts @@ -5,7 +5,7 @@ //// /** //// * @typedef {Object} Person -//// * /*1*/@property {string} personName +//// * @property {string} /*1*/personName //// * @property {number} personAge //// */ //// diff --git a/tests/cases/fourslash/server/typedefinition01.ts b/tests/cases/fourslash/server/typedefinition01.ts index bde9f4dc4d8..40e1dcf43bb 100644 --- a/tests/cases/fourslash/server/typedefinition01.ts +++ b/tests/cases/fourslash/server/typedefinition01.ts @@ -5,8 +5,6 @@ ////var x/*1*/ = new n.Foo(); // @Filename: a.ts -//// /*2*/export class Foo {} +////export class /*2*/Foo {} -goTo.marker('1'); -goTo.type(); -verify.caretAtMarker('2'); \ No newline at end of file +verify.goToType("1", "2"); diff --git a/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts b/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts index 1679563942c..67e8c44c84c 100644 --- a/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts +++ b/tests/cases/fourslash/shims-pp/getDefinitionAtPosition.ts @@ -2,10 +2,10 @@ // @Filename: goToDefinitionDifferentFile_Definition.ts ////var /*remoteVariableDefinition*/remoteVariable; -/////*remoteFunctionDefinition*/function remoteFunction() { } -/////*remoteClassDefinition*/class remoteClass { } -/////*remoteInterfaceDefinition*/interface remoteInterface{ } -/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} +////function /*remoteFunctionDefinition*/remoteFunction() { } +////class /*remoteClassDefinition*/remoteClass { } +////interface /*remoteInterfaceDefinition*/remoteInterface{ } +////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;} // @Filename: goToDefinitionDifferentFile_Consumption.ts /////*remoteVariableReference*/remoteVariable = 1; diff --git a/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts b/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts index 6b34e7e4886..b6bbd839003 100644 --- a/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts +++ b/tests/cases/fourslash/shims-pp/goToTypeDefinition.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinition_Definition.ts -/////*definition*/class C { +////class /*definition*/C { //// p; ////} ////var c: C; @@ -9,6 +9,4 @@ // @Filename: goToTypeDefinition_Consumption.ts /////*reference*/c = undefined; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/shims/getDefinitionAtPosition.ts b/tests/cases/fourslash/shims/getDefinitionAtPosition.ts index 1679563942c..67e8c44c84c 100644 --- a/tests/cases/fourslash/shims/getDefinitionAtPosition.ts +++ b/tests/cases/fourslash/shims/getDefinitionAtPosition.ts @@ -2,10 +2,10 @@ // @Filename: goToDefinitionDifferentFile_Definition.ts ////var /*remoteVariableDefinition*/remoteVariable; -/////*remoteFunctionDefinition*/function remoteFunction() { } -/////*remoteClassDefinition*/class remoteClass { } -/////*remoteInterfaceDefinition*/interface remoteInterface{ } -/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} +////function /*remoteFunctionDefinition*/remoteFunction() { } +////class /*remoteClassDefinition*/remoteClass { } +////interface /*remoteInterfaceDefinition*/remoteInterface{ } +////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;} // @Filename: goToDefinitionDifferentFile_Consumption.ts /////*remoteVariableReference*/remoteVariable = 1; diff --git a/tests/cases/fourslash/shims/goToTypeDefinition.ts b/tests/cases/fourslash/shims/goToTypeDefinition.ts index 6b34e7e4886..b6bbd839003 100644 --- a/tests/cases/fourslash/shims/goToTypeDefinition.ts +++ b/tests/cases/fourslash/shims/goToTypeDefinition.ts @@ -1,7 +1,7 @@ /// // @Filename: goToTypeDefinition_Definition.ts -/////*definition*/class C { +////class /*definition*/C { //// p; ////} ////var c: C; @@ -9,6 +9,4 @@ // @Filename: goToTypeDefinition_Consumption.ts /////*reference*/c = undefined; -goTo.marker('reference'); -goTo.type(); -verify.caretAtMarker('definition'); +verify.goToType("reference", "definition"); diff --git a/tests/cases/fourslash/tsxGoToDefinitionClasses.ts b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts index 9c54834534d..fb76080f6df 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionClasses.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionClasses.ts @@ -6,7 +6,7 @@ //// interface IntrinsicElements { } //// interface ElementAttributesProperty { props; } //// } -//// /*ct*/class MyClass { +//// class /*ct*/MyClass { //// props: { //// /*pt*/foo: string; //// } From 463626d56f3b52712a23f09c81f411763df0bf19 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 9 Jan 2017 13:51:25 -0800 Subject: [PATCH 080/175] Move helper to services/utilities --- src/compiler/utilities.ts | 4 ---- src/services/utilities.ts | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 6a017fd996d..192ef888b11 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4318,10 +4318,6 @@ namespace ts { return createTextSpan(start, end - start); } - export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { - return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); - } - export function textChangeRangeNewSpan(range: TextChangeRange) { return createTextSpan(range.span.start, range.newLength); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 76a3b43da21..47608a59e75 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1112,6 +1112,10 @@ namespace ts { return !tripleSlashDirectivePrefixRegex.test(commentText); } } + + export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { + return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } } // Display-part writer helpers From fc641fa2752dfd0049b51516b4ac642ca5850c18 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 9 Jan 2017 16:51:30 -0800 Subject: [PATCH 081/175] Properly check T[K] constraints in type relationships --- src/compiler/checker.ts | 2 +- src/compiler/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3769f2493b3..2bdfe9c0c03 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7206,7 +7206,7 @@ namespace ts { return related === RelationComparisonResult.Succeeded; } } - if (source.flags & TypeFlags.StructuredOrTypeParameter || target.flags & TypeFlags.StructuredOrTypeParameter) { + if (source.flags & TypeFlags.StructuredOrTypeVariable || target.flags & TypeFlags.StructuredOrTypeVariable) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6eebb0b99d7..8e626384533 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2803,7 +2803,7 @@ namespace ts { EnumLike = Enum | EnumLiteral, UnionOrIntersection = Union | Intersection, StructuredType = Object | Union | Intersection, - StructuredOrTypeParameter = StructuredType | TypeParameter | Index, + StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess, TypeVariable = TypeParameter | IndexedAccess, // 'Narrowable' types are types where narrowing actually narrows. From 81e891812e96e5b03286e61ebd0ce412cf2345bd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 9 Jan 2017 16:51:46 -0800 Subject: [PATCH 082/175] Add regression test --- .../reference/keyofAndIndexedAccess.js | 51 +++++++++++ .../reference/keyofAndIndexedAccess.symbols | 80 +++++++++++++++++ .../reference/keyofAndIndexedAccess.types | 86 +++++++++++++++++++ .../types/keyof/keyofAndIndexedAccess.ts | 27 ++++++ 4 files changed, 244 insertions(+) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.js b/tests/baselines/reference/keyofAndIndexedAccess.js index 3ad7bdd79f8..f5c2624fc40 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.js +++ b/tests/baselines/reference/keyofAndIndexedAccess.js @@ -463,6 +463,33 @@ let MyThingy: { [key in KeyTypes]: string[] }; function addToMyThingy(key: S) { MyThingy[key].push("a"); } + +// Repro from #13285 + +function updateIds, K extends string>( + obj: T, + idFields: K[], + idMapping: { [oldId: string]: string } +): Record { + for (const idField of idFields) { + const newId = idMapping[obj[idField]]; + if (newId) { + obj[idField] = newId; + } + } + return obj; +} + +// Repro from #13285 + +function updateIds2( + obj: T, + key: K, + stringMap: { [oldId: string]: string } +) { + var x = obj[key]; + stringMap[x]; // Should be OK. +} //// [keyofAndIndexedAccess.js] @@ -769,6 +796,22 @@ var MyThingy; function addToMyThingy(key) { MyThingy[key].push("a"); } +// Repro from #13285 +function updateIds(obj, idFields, idMapping) { + for (var _i = 0, idFields_1 = idFields; _i < idFields_1.length; _i++) { + var idField = idFields_1[_i]; + var newId = idMapping[obj[idField]]; + if (newId) { + obj[idField] = newId; + } + } + return obj; +} +// Repro from #13285 +function updateIds2(obj, key, stringMap) { + var x = obj[key]; + stringMap[x]; // Should be OK. +} //// [keyofAndIndexedAccess.d.ts] @@ -986,3 +1029,11 @@ declare let MyThingy: { [key in KeyTypes]: string[]; }; declare function addToMyThingy(key: S): void; +declare function updateIds, K extends string>(obj: T, idFields: K[], idMapping: { + [oldId: string]: string; +}): Record; +declare function updateIds2(obj: T, key: K, stringMap: { + [oldId: string]: string; +}): void; diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index fb8129a5301..a6eb03dd6e5 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -1699,3 +1699,83 @@ function addToMyThingy(key: S) { >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) } +// Repro from #13285 + +function updateIds, K extends string>( +>updateIds : Symbol(updateIds, Decl(keyofAndIndexedAccess.ts, 463, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47)) + + obj: T, +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 19)) + + idFields: K[], +>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 468, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47)) + + idMapping: { [oldId: string]: string } +>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 469, 18)) +>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 470, 18)) + +): Record { +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47)) + + for (const idField of idFields) { +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14)) +>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 468, 11)) + + const newId = idMapping[obj[idField]]; +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13)) +>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 469, 18)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14)) + + if (newId) { +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13)) + + obj[idField] = newId; +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14)) +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13)) + } + } + return obj; +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66)) +} + +// Repro from #13285 + +function updateIds2( +>updateIds2 : Symbol(updateIds2, Decl(keyofAndIndexedAccess.ts, 479, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 483, 33)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 483, 54)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20)) + + obj: T, +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 483, 74)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20)) + + key: K, +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 484, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 483, 54)) + + stringMap: { [oldId: string]: string } +>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 485, 11)) +>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 486, 18)) + +) { + var x = obj[key]; +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 488, 7)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 483, 74)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 484, 11)) + + stringMap[x]; // Should be OK. +>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 485, 11)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 488, 7)) +} + diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index ccf0bde4e1c..920758c8beb 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -2013,3 +2013,89 @@ function addToMyThingy(key: S) { >"a" : "a" } +// Repro from #13285 + +function updateIds, K extends string>( +>updateIds : , K extends string>(obj: T, idFields: K[], idMapping: { [oldId: string]: string; }) => Record +>T : T +>Record : Record +>K : K +>K : K + + obj: T, +>obj : T +>T : T + + idFields: K[], +>idFields : K[] +>K : K + + idMapping: { [oldId: string]: string } +>idMapping : { [oldId: string]: string; } +>oldId : string + +): Record { +>Record : Record +>K : K + + for (const idField of idFields) { +>idField : K +>idFields : K[] + + const newId = idMapping[obj[idField]]; +>newId : { [oldId: string]: string; }[T[K]] +>idMapping[obj[idField]] : { [oldId: string]: string; }[T[K]] +>idMapping : { [oldId: string]: string; } +>obj[idField] : T[K] +>obj : T +>idField : K + + if (newId) { +>newId : { [oldId: string]: string; }[T[K]] + + obj[idField] = newId; +>obj[idField] = newId : { [oldId: string]: string; }[T[K]] +>obj[idField] : T[K] +>obj : T +>idField : K +>newId : { [oldId: string]: string; }[T[K]] + } + } + return obj; +>obj : T +} + +// Repro from #13285 + +function updateIds2( +>updateIds2 : (obj: T, key: K, stringMap: { [oldId: string]: string; }) => void +>T : T +>x : string +>K : K +>T : T + + obj: T, +>obj : T +>T : T + + key: K, +>key : K +>K : K + + stringMap: { [oldId: string]: string } +>stringMap : { [oldId: string]: string; } +>oldId : string + +) { + var x = obj[key]; +>x : T[K] +>obj[key] : T[K] +>obj : T +>key : K + + stringMap[x]; // Should be OK. +>stringMap[x] : { [oldId: string]: string; }[T[K]] +>stringMap : { [oldId: string]: string; } +>x : T[K] +} + diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts index 0ef73c736f4..770dc2ead98 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts @@ -464,3 +464,30 @@ let MyThingy: { [key in KeyTypes]: string[] }; function addToMyThingy(key: S) { MyThingy[key].push("a"); } + +// Repro from #13285 + +function updateIds, K extends string>( + obj: T, + idFields: K[], + idMapping: { [oldId: string]: string } +): Record { + for (const idField of idFields) { + const newId = idMapping[obj[idField]]; + if (newId) { + obj[idField] = newId; + } + } + return obj; +} + +// Repro from #13285 + +function updateIds2( + obj: T, + key: K, + stringMap: { [oldId: string]: string } +) { + var x = obj[key]; + stringMap[x]; // Should be OK. +} From 41af749196c32bdac1a61be462c348a0f014c326 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Mon, 9 Jan 2017 21:29:34 -0800 Subject: [PATCH 083/175] Update based on feedback --- src/compiler/commandLineParser.ts | 4 ++-- src/compiler/diagnosticMessages.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 9111a72eb2d..3a4d5c6b1f7 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -212,8 +212,8 @@ namespace ts { shortName: "p", type: "string", isFilePath: true, - description: Diagnostics.Compile_the_project_in_the_given_directory_using_tsconfig_json_or_the_specified_config_file, - paramType: Diagnostics.DIRECTORY_OR_FILE + description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 2230ffdbac0..6bdf9932fca 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2513,7 +2513,7 @@ "category": "Message", "code": 6019 }, - "Compile the project in the given directory, using 'tsconfig.json' or the specified config file.": { + "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'": { "category": "Message", "code": 6020 }, @@ -2573,7 +2573,7 @@ "category": "Message", "code": 6039 }, - "DIRECTORY_OR_FILE": { + "FILE OR DIRECTORY": { "category": "Message", "code": 6040 }, From c9e301f236f7fad0f6dfb51f7e622f8b189d7207 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 10 Jan 2017 08:55:15 -0800 Subject: [PATCH 084/175] Test:object rest skips only class methods Previously, it skipped all methods. --- tests/baselines/reference/objectRest.js | 9 ++ tests/baselines/reference/objectRest.symbols | 82 ++++++++++++------- tests/baselines/reference/objectRest.types | 22 +++++ .../conformance/types/rest/objectRest.ts | 7 ++ 4 files changed, 90 insertions(+), 30 deletions(-) diff --git a/tests/baselines/reference/objectRest.js b/tests/baselines/reference/objectRest.js index 48a1bf8daf8..59eb11542c0 100644 --- a/tests/baselines/reference/objectRest.js +++ b/tests/baselines/reference/objectRest.js @@ -29,8 +29,15 @@ class Removable { removed: string; remainder: string; } +interface I { + m(): void; + removed: string; + remainder: string; +} var removable = new Removable(); var { removed, ...removableRest } = removable; +var i: I = removable; +var { removed, ...removableRest2 } = i; let computed = 'b'; let computed2 = 'a'; @@ -74,6 +81,8 @@ class Removable { } var removable = new Removable(); var { removed } = removable, removableRest = __rest(removable, ["removed"]); +var i = removable; +var { removed } = i, removableRest2 = __rest(i, ["removed"]); let computed = 'b'; let computed2 = 'a'; var _g = computed, stillNotGreat = o[_g], _h = computed2, soSo = o[_h], o = __rest(o, [typeof _g === "symbol" ? _g : _g + "", typeof _h === "symbol" ? _h : _h + ""]); diff --git a/tests/baselines/reference/objectRest.symbols b/tests/baselines/reference/objectRest.symbols index 46309392135..2992220d8b2 100644 --- a/tests/baselines/reference/objectRest.symbols +++ b/tests/baselines/reference/objectRest.symbols @@ -1,42 +1,42 @@ === tests/cases/conformance/types/rest/objectRest.ts === var o = { a: 1, b: 'no' } ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) >a : Symbol(a, Decl(objectRest.ts, 0, 9)) >b : Symbol(b, Decl(objectRest.ts, 0, 15)) var { ...clone } = o; >clone : Symbol(clone, Decl(objectRest.ts, 1, 5)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { a, ...justB } = o; >a : Symbol(a, Decl(objectRest.ts, 2, 5), Decl(objectRest.ts, 3, 5)) >justB : Symbol(justB, Decl(objectRest.ts, 2, 8)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { a, b: renamed, ...empty } = o; >a : Symbol(a, Decl(objectRest.ts, 2, 5), Decl(objectRest.ts, 3, 5)) >b : Symbol(b, Decl(objectRest.ts, 0, 15)) >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >empty : Symbol(empty, Decl(objectRest.ts, 3, 20)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { ['b']: renamed, ...justA } = o; >'b' : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { 'b': renamed, ...justA } = o; >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { b: { '0': n, '1': oooo }, ...justA } = o; >b : Symbol(b, Decl(objectRest.ts, 0, 15)) >n : Symbol(n, Decl(objectRest.ts, 6, 10)) >oooo : Symbol(oooo, Decl(objectRest.ts, 6, 18)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) let o2 = { c: 'terrible idea?', d: 'yes' }; >o2 : Symbol(o2, Decl(objectRest.ts, 8, 3)) @@ -138,41 +138,63 @@ class Removable { remainder: string; >remainder : Symbol(Removable.remainder, Decl(objectRest.ts, 27, 20)) } +interface I { +>I : Symbol(I, Decl(objectRest.ts, 29, 1)) + + m(): void; +>m : Symbol(I.m, Decl(objectRest.ts, 30, 13)) + + removed: string; +>removed : Symbol(I.removed, Decl(objectRest.ts, 31, 14)) + + remainder: string; +>remainder : Symbol(I.remainder, Decl(objectRest.ts, 32, 20)) +} var removable = new Removable(); ->removable : Symbol(removable, Decl(objectRest.ts, 30, 3)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) >Removable : Symbol(Removable, Decl(objectRest.ts, 18, 35)) var { removed, ...removableRest } = removable; ->removed : Symbol(removed, Decl(objectRest.ts, 31, 5)) ->removableRest : Symbol(removableRest, Decl(objectRest.ts, 31, 14)) ->removable : Symbol(removable, Decl(objectRest.ts, 30, 3)) +>removed : Symbol(removed, Decl(objectRest.ts, 36, 5), Decl(objectRest.ts, 38, 5)) +>removableRest : Symbol(removableRest, Decl(objectRest.ts, 36, 14)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) + +var i: I = removable; +>i : Symbol(i, Decl(objectRest.ts, 37, 3)) +>I : Symbol(I, Decl(objectRest.ts, 29, 1)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) + +var { removed, ...removableRest2 } = i; +>removed : Symbol(removed, Decl(objectRest.ts, 36, 5), Decl(objectRest.ts, 38, 5)) +>removableRest2 : Symbol(removableRest2, Decl(objectRest.ts, 38, 14)) +>i : Symbol(i, Decl(objectRest.ts, 37, 3)) let computed = 'b'; ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) let computed2 = 'a'; ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) ->stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 35, 5)) ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) ->soSo : Symbol(soSo, Decl(objectRest.ts, 35, 32)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) +>stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 42, 5)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) +>soSo : Symbol(soSo, Decl(objectRest.ts, 42, 32)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) ({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) ->stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 35, 5)) ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) ->soSo : Symbol(soSo, Decl(objectRest.ts, 35, 32)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) +>stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 42, 5)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) +>soSo : Symbol(soSo, Decl(objectRest.ts, 42, 32)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; ->noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 38, 3)) ->aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25)) ->notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39)) ->aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25)) ->notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39)) +>noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 45, 3)) +>aNumber : Symbol(aNumber, Decl(objectRest.ts, 45, 25)) +>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 45, 39)) +>aNumber : Symbol(aNumber, Decl(objectRest.ts, 45, 25)) +>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 45, 39)) diff --git a/tests/baselines/reference/objectRest.types b/tests/baselines/reference/objectRest.types index 1dc05741713..5347f09f5a3 100644 --- a/tests/baselines/reference/objectRest.types +++ b/tests/baselines/reference/objectRest.types @@ -158,6 +158,18 @@ class Removable { remainder: string; >remainder : string } +interface I { +>I : I + + m(): void; +>m : () => void + + removed: string; +>removed : string + + remainder: string; +>remainder : string +} var removable = new Removable(); >removable : Removable >new Removable() : Removable @@ -168,6 +180,16 @@ var { removed, ...removableRest } = removable; >removableRest : { both: number; remainder: string; } >removable : Removable +var i: I = removable; +>i : I +>I : I +>removable : Removable + +var { removed, ...removableRest2 } = i; +>removed : string +>removableRest2 : { m(): void; remainder: string; } +>i : I + let computed = 'b'; >computed : string >'b' : "b" diff --git a/tests/cases/conformance/types/rest/objectRest.ts b/tests/cases/conformance/types/rest/objectRest.ts index 2fba5d0b6dc..77f0fca1ed7 100644 --- a/tests/cases/conformance/types/rest/objectRest.ts +++ b/tests/cases/conformance/types/rest/objectRest.ts @@ -29,8 +29,15 @@ class Removable { removed: string; remainder: string; } +interface I { + m(): void; + removed: string; + remainder: string; +} var removable = new Removable(); var { removed, ...removableRest } = removable; +var i: I = removable; +var { removed, ...removableRest2 } = i; let computed = 'b'; let computed2 = 'a'; From 945e65f4d8d79dc7bd25a9e818a1999a48664ad7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 10 Jan 2017 08:55:46 -0800 Subject: [PATCH 085/175] Object rest skips only class methods Previously, it skipped all methods --- src/compiler/checker.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 54f0758b3a9..f828fb02c0c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3125,9 +3125,8 @@ namespace ts { for (const prop of getPropertiesOfType(source)) { const inNamesToRemove = prop.name in names; const isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected); - const isMethod = prop.flags & SymbolFlags.Method; const isSetOnlyAccessor = prop.flags & SymbolFlags.SetAccessor && !(prop.flags & SymbolFlags.GetAccessor); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { members[prop.name] = prop; } } From 2ae5806210d0ccd508c1adeec01e5a056ebd33d0 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 10 Jan 2017 13:04:32 -0800 Subject: [PATCH 086/175] Include "export" modifier on function assigned to an export (`export const x = () => 0;`). --- src/services/navigationBar.ts | 11 ++- .../navigationBarItemsFunctionProperties.ts | 4 - .../navigationBarItemsNamedArrowFunctions.ts | 78 +++++++++++++++++++ 3 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 28f69a0b488..9735ce4528b 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -514,7 +514,7 @@ namespace ts.NavigationBar { return { text: getItemName(n.node), kind: getNodeKind(n.node), - kindModifiers: getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: map(n.children, convertToTree) }; @@ -524,7 +524,7 @@ namespace ts.NavigationBar { return { text: getItemName(n.node), kind: getNodeKind(n.node), - kindModifiers: getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -594,6 +594,13 @@ namespace ts.NavigationBar { : createTextSpanFromNode(node, curSourceFile); } + function getModifiers(node: ts.Node): string { + if (node.parent && node.parent.kind === SyntaxKind.VariableDeclaration) { + node = node.parent; + } + return getNodeModifiers(node); + } + function getFunctionOrClassName(node: FunctionExpression | FunctionDeclaration | ArrowFunction | ClassLikeDeclaration): string { if (node.name && getFullWidth(node.name) > 0) { return declarationNameToString(node.name); diff --git a/tests/cases/fourslash/navigationBarItemsFunctionProperties.ts b/tests/cases/fourslash/navigationBarItemsFunctionProperties.ts index 75c20736b41..9844f53d879 100644 --- a/tests/cases/fourslash/navigationBarItemsFunctionProperties.ts +++ b/tests/cases/fourslash/navigationBarItemsFunctionProperties.ts @@ -6,10 +6,6 @@ //// .a = function() { }; //// })(); -function navExact(name: string, kind: string) { - return; -} - verify.navigationTree( { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts b/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts new file mode 100644 index 00000000000..32abf4092c7 --- /dev/null +++ b/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts @@ -0,0 +1,78 @@ +/// + +////export const value = 2; +////export const func = () => 2; +////export const func2 = function() { }; +////export function exportedFunction() { } + +verify.navigationBar([ + { + "text": "\"navigationBarItemsNamedArrowFunctions\"", + "kind": "module", + "childItems": [ + { + "text": "exportedFunction", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "func", + "kind": "function" + }, + { + "text": "func2", + "kind": "function" + }, + { + "text": "value", + "kind": "const", + "kindModifiers": "export" + } + ] + }, + { + "text": "exportedFunction", + "kind": "function", + "kindModifiers": "export", + "indent": 1 + }, + { + "text": "func", + "kind": "function", + "kindModifiers": "export", + "indent": 1 + }, + { + "text": "func2", + "kind": "function", + "kindModifiers": "export", + "indent": 1 + } +]); + +verify.navigationTree({ + "text": "\"navigationBarItemsNamedArrowFunctions\"", + "kind": "module", + "childItems": [ + { + "text": "exportedFunction", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "func", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "func2", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "value", + "kind": "const", + "kindModifiers": "export" + } + ] +}); From 54f12307601c2dfb364575210c131da7f7a71ba6 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Tue, 10 Jan 2017 16:58:43 -0800 Subject: [PATCH 087/175] Change the remove unused local code fix message --- src/compiler/diagnosticMessages.json | 2 +- src/services/codefixes/unusedIdentifierFixes.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6bdf9932fca..bce99cbaf39 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3247,7 +3247,7 @@ "category": "Message", "code": 90003 }, - "Remove unused identifiers.": { + "Remove the unused identifier: {0}": { "category": "Message", "code": 90004 }, diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 8e14bdcb73e..5c42fc8e6e9 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -146,7 +146,7 @@ namespace ts.codefix { function createCodeFix(newText: string, start: number, length: number): CodeAction[] { return [{ - description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers), + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_the_unused_identifier_Colon_0), { 0: token.getText() }), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText, span: { start, length } }] From 0c7e4bbb455b99725d49fe3e89a353656048e9b6 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Tue, 10 Jan 2017 17:55:52 -0800 Subject: [PATCH 088/175] Update the message --- src/compiler/diagnosticMessages.json | 2 +- src/services/codefixes/unusedIdentifierFixes.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index bce99cbaf39..52fc401d1f1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3247,7 +3247,7 @@ "category": "Message", "code": 90003 }, - "Remove the unused identifier: {0}": { + "Remove declaration for: {0}": { "category": "Message", "code": 90004 }, diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 5c42fc8e6e9..2784a09a504 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -146,7 +146,7 @@ namespace ts.codefix { function createCodeFix(newText: string, start: number, length: number): CodeAction[] { return [{ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_the_unused_identifier_Colon_0), { 0: token.getText() }), + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText, span: { start, length } }] From 37e18d974158b73d3eb9c7d07b65b34df836120d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 11 Jan 2017 09:52:50 -0800 Subject: [PATCH 089/175] Add `createMapFromTemplate` helper --- src/compiler/checker.ts | 6 ++--- src/compiler/commandLineParser.ts | 12 +++++----- src/compiler/core.ts | 7 +++++- src/compiler/scanner.ts | 2 +- src/compiler/transformers/jsx.ts | 2 +- src/compiler/utilities.ts | 2 +- src/harness/fourslash.ts | 2 +- .../unittests/cachingInServerLSHost.ts | 4 ++-- .../unittests/configurationExtension.ts | 2 +- src/harness/unittests/moduleResolution.ts | 22 +++++++++---------- .../unittests/reuseProgramStructure.ts | 12 +++++----- src/server/editorServices.ts | 2 +- src/services/jsTyping.ts | 2 +- src/services/transpile.ts | 2 +- 14 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3348db7272a..efa10943793 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -315,7 +315,7 @@ namespace ts { NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy, } - const typeofEQFacts = createMap({ + const typeofEQFacts = createMapFromTemplate({ "string": TypeFacts.TypeofEQString, "number": TypeFacts.TypeofEQNumber, "boolean": TypeFacts.TypeofEQBoolean, @@ -325,7 +325,7 @@ namespace ts { "function": TypeFacts.TypeofEQFunction }); - const typeofNEFacts = createMap({ + const typeofNEFacts = createMapFromTemplate({ "string": TypeFacts.TypeofNEString, "number": TypeFacts.TypeofNENumber, "boolean": TypeFacts.TypeofNEBoolean, @@ -335,7 +335,7 @@ namespace ts { "function": TypeFacts.TypeofNEFunction }); - const typeofTypesByName = createMap({ + const typeofTypesByName = createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index a8c55a88e3f..b222df53630 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -65,7 +65,7 @@ namespace ts { }, { name: "jsx", - type: createMap({ + type: createMapFromTemplate({ "preserve": JsxEmit.Preserve, "react": JsxEmit.React }), @@ -100,7 +100,7 @@ namespace ts { { name: "module", shortName: "m", - type: createMap({ + type: createMapFromTemplate({ "none": ModuleKind.None, "commonjs": ModuleKind.CommonJS, "amd": ModuleKind.AMD, @@ -114,7 +114,7 @@ namespace ts { }, { name: "newLine", - type: createMap({ + type: createMapFromTemplate({ "crlf": NewLineKind.CarriageReturnLineFeed, "lf": NewLineKind.LineFeed }), @@ -263,7 +263,7 @@ namespace ts { { name: "target", shortName: "t", - type: createMap({ + type: createMapFromTemplate({ "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES2015, @@ -300,7 +300,7 @@ namespace ts { }, { name: "moduleResolution", - type: createMap({ + type: createMapFromTemplate({ "node": ModuleResolutionKind.NodeJs, "classic": ModuleResolutionKind.Classic, }), @@ -409,7 +409,7 @@ namespace ts { type: "list", element: { name: "lib", - type: createMap({ + type: createMapFromTemplate({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 34c47bcd2f4..7e9cb460ba8 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -40,7 +40,12 @@ namespace ts { } /** Create a new map. If a template object is provided, the map will copy entries from it. */ - export function createMap(template?: MapLike): Map { + export function createMap(): Map { + return new MapCtr(); + } + + //!!! + export function createMapFromTemplate(template?: MapLike): Map { const map: Map = new MapCtr(); // Copies keys/values from template. Note that for..in will not throw if diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 259eaa0f5f3..84f1f624d95 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -56,7 +56,7 @@ namespace ts { tryScan(callback: () => T): T; } - const textToToken = createMap({ + const textToToken = createMapFromTemplate({ "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 4879b3c4fa3..1307a7f8551 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -286,7 +286,7 @@ namespace ts { } } - const entities = createMap({ + const entities = createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index d3e1f076638..932e75d0345 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2351,7 +2351,7 @@ namespace ts { // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. const escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - const escapedCharsMap = createMap({ + const escapedCharsMap = createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index ff4964b284b..a75acec53a5 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -90,7 +90,7 @@ namespace FourSlash { export import IndentStyle = ts.IndentStyle; - const entityMap = ts.createMap({ + const entityMap = ts.createMapFromTemplate({ "&": "&", "\"": """, "'": "'", diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 8389186c486..caeab18958e 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -86,7 +86,7 @@ namespace ts { content: `foo()` }; - const serverHost = createDefaultServerHost(createMap({ [root.name]: root, [imported.name]: imported })); + const serverHost = createDefaultServerHost(createMapFromTemplate({ [root.name]: root, [imported.name]: imported })); const { project, rootScriptInfo } = createProject(root.name, serverHost); // ensure that imported file was found @@ -170,7 +170,7 @@ namespace ts { content: `export var y = 1` }; - const fileMap = createMap({ [root.name]: root }); + const fileMap = createMapFromTemplate({ [root.name]: root }); const serverHost = createDefaultServerHost(fileMap); const originalFileExists = serverHost.fileExists; diff --git a/src/harness/unittests/configurationExtension.ts b/src/harness/unittests/configurationExtension.ts index c68d07f5123..886ee5d54b5 100644 --- a/src/harness/unittests/configurationExtension.ts +++ b/src/harness/unittests/configurationExtension.ts @@ -2,7 +2,7 @@ /// namespace ts { - const testContents = createMap({ + const testContents = createMapFromTemplate({ "/dev/tsconfig.json": `{ "extends": "./configs/base", "files": [ diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 8e4ace38655..aa30f1e01e2 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -331,7 +331,7 @@ namespace ts { } it("should find all modules", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c/first/shared.ts": ` class A {} export = A`, @@ -350,7 +350,7 @@ export = C; }); it("should find modules in node_modules", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/parent/node_modules/mod/index.d.ts": "export var x", "/parent/app/myapp.ts": `import {x} from "mod"` }); @@ -358,7 +358,7 @@ export = C; }); it("should find file referenced via absolute and relative names", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/b.ts": "var x" }); @@ -409,7 +409,7 @@ export = C; } it("should succeed when the same file is referenced using absolute and relative names", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" }); @@ -417,7 +417,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (tripleslash references)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" }); @@ -425,7 +425,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (imports)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/d.ts": "export var x" }); @@ -433,7 +433,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (imports, relative module names)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "moduleA.ts": `import {x} from "./ModuleB"`, "moduleB.ts": "export var x" }); @@ -441,7 +441,7 @@ export = C; }); it("should fail when two files exist on disk that differs only in casing", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/D.ts": "export var x", "/a/b/d.ts": "export var y" @@ -450,7 +450,7 @@ export = C; }); it("should fail when module name in 'require' calls has inconsistent casing", () => { - const files = createMap({ + const files = createMapFromTemplate({ "moduleA.ts": `import a = require("./ModuleC")`, "moduleB.ts": `import a = require("./moduleC")`, "moduleC.ts": "export var x" @@ -459,7 +459,7 @@ export = C; }); it("should fail when module names in 'require' calls has inconsistent casing and current directory has uppercase chars", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/B/c/moduleA.ts": `import a = require("./ModuleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", @@ -471,7 +471,7 @@ import b = require("./moduleB"); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], [1149]); }); it("should not fail when module names in 'require' calls has consistent casing and current directory has uppercase chars", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/B/c/moduleA.ts": `import a = require("./moduleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 8a89b8d27c6..d13dd7a26fa 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -322,7 +322,7 @@ namespace ts { const options: CompilerOptions = { target }; const program_1 = newProgram(files, ["a.ts"], options); - checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": createResolvedModule("b.ts") })); + checkResolvedModulesCache(program_1, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts") })); checkResolvedModulesCache(program_1, "b.ts", undefined); const program_2 = updateProgram(program_1, ["a.ts"], options, files => { @@ -331,7 +331,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": createResolvedModule("b.ts") })); + checkResolvedModulesCache(program_1, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts") })); checkResolvedModulesCache(program_1, "b.ts", undefined); // imports has changed - program is not reused @@ -348,7 +348,7 @@ namespace ts { files[0].text = files[0].text.updateImportsAndExports(newImports); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedModulesCache(program_4, "a.ts", createMap({ "b": createResolvedModule("b.ts"), "c": undefined })); + checkResolvedModulesCache(program_4, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts"), "c": undefined })); }); it("resolved type directives cache follows type directives", () => { @@ -359,7 +359,7 @@ namespace ts { const options: CompilerOptions = { target, typeRoots: ["/types"] }; const program_1 = newProgram(files, ["/a.ts"], options); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); const program_2 = updateProgram(program_1, ["/a.ts"], options, files => { @@ -368,7 +368,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); // type reference directives has changed - program is not reused @@ -386,7 +386,7 @@ namespace ts { files[0].text = files[0].text.updateReferences(newReferences); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); }); it("can reuse ambient module declarations from non-modified files", () => { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 8153804a7bd..25d58142a06 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -51,7 +51,7 @@ namespace ts.server { } const compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(optionDeclarations); - const indentStyle = createMap({ + const indentStyle = createMapFromTemplate({ "none": IndentStyle.None, "block": IndentStyle.Block, "smart": IndentStyle.Smart diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index e587a14b459..248ceef1bd3 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -76,7 +76,7 @@ namespace ts.JsTyping { if (!safeList) { const result = readConfigFile(safeListPath, (path: string) => host.readFile(path)); - safeList = result.config ? createMap(result.config) : EmptySafeList; + safeList = result.config ? createMapFromTemplate(result.config) : EmptySafeList; } const filesToWatch: string[] = []; diff --git a/src/services/transpile.ts b/src/services/transpile.ts index b72399384b7..0b90e9d030b 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -63,7 +63,7 @@ } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = createMapFromTemplate(transpileOptions.renamedDependencies); } const newLine = getNewLineCharacter(options); From 13ce0e9414a992a4b33f7115664ceb0b70ec18ae Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 11 Jan 2017 11:48:49 -0800 Subject: [PATCH 090/175] Fix type relations for 'keyof T' type where T is union or intersection --- src/compiler/checker.ts | 36 +++++++++++++++++------------------- src/compiler/types.ts | 4 +++- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f828fb02c0c..8d949d6ac79 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4753,15 +4753,15 @@ namespace ts { getPropertiesOfObjectType(type); } - function getConstraintOfTypeVariable(type: TypeVariable): Type { - return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : getBaseConstraintOfTypeVariable(type); + function getConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { + return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type { return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } - function getBaseConstraintOfTypeVariable(type: TypeVariable): Type { + function getBaseConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { const constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } @@ -4775,15 +4775,15 @@ namespace ts { * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint * circularly references the type variable. */ - function getResolvedBaseConstraint(type: TypeVariable): Type { + function getResolvedBaseConstraint(type: TypeVariable | UnionOrIntersectionType): Type { let typeStack: Type[]; let circular: boolean; - if (!type.resolvedApparentType) { + if (!type.resolvedBaseConstraint) { typeStack = []; const constraint = getBaseConstraint(type); - type.resolvedApparentType = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; function getBaseConstraint(t: Type): Type { if (contains(typeStack, t)) { @@ -4834,7 +4834,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 ? getBaseConstraintOfTypeVariable(type) || emptyObjectType : type; + const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfType(type) || emptyObjectType : type; return t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : @@ -7427,14 +7427,12 @@ namespace ts { return result; } } - // Given a type variable T with a constraint C, a type S is assignable to - // keyof T if S is assignable to keyof C. - if ((target).type.flags & TypeFlags.TypeVariable) { - const constraint = getConstraintOfTypeVariable((target).type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + const constraint = getConstraintOfType((target).type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -7448,7 +7446,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 = getBaseConstraintOfTypeVariable(target); + const constraint = getBaseConstraintOfType(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -7488,7 +7486,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 = getBaseConstraintOfTypeVariable(source); + const constraint = getBaseConstraintOfType(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -15207,7 +15205,7 @@ namespace ts { function isLiteralContextualType(contextualType: Type) { if (contextualType) { if (contextualType.flags & TypeFlags.TypeVariable) { - const constraint = getBaseConstraintOfTypeVariable(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. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8827aea633a..954ad21ba29 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2923,6 +2923,8 @@ namespace ts { /* @internal */ resolvedIndexType: IndexType; /* @internal */ + resolvedBaseConstraint: Type; + /* @internal */ couldContainTypeVariables: boolean; } @@ -2982,7 +2984,7 @@ namespace ts { export interface TypeVariable extends Type { /* @internal */ - resolvedApparentType: Type; + resolvedBaseConstraint: Type; /* @internal */ resolvedIndexType: IndexType; } From 1f4cbcefb1cf0735a4925fb7420d338e596c71d5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 11 Jan 2017 11:50:30 -0800 Subject: [PATCH 091/175] Remove incorrect type relationship --- src/compiler/checker.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8d949d6ac79..cc4afc8aa3e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7409,16 +7409,6 @@ namespace ts { } } } - else { - // Given a type parameter K with a constraint keyof T, a type S is - // assignable to K if S is assignable to keyof T. - const constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & TypeFlags.Index) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & TypeFlags.Index) { // A keyof S is related to a keyof T if T is related to S. From 5abd3230a4b7470161cba25456501e4805fd48ab Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 11 Jan 2017 11:50:41 -0800 Subject: [PATCH 092/175] Add regression test --- .../reference/keyofAndIndexedAccess.js | 19 ++++ .../reference/keyofAndIndexedAccess.symbols | 103 +++++++++++------- .../reference/keyofAndIndexedAccess.types | 29 +++++ .../types/keyof/keyofAndIndexedAccess.ts | 10 ++ 4 files changed, 123 insertions(+), 38 deletions(-) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.js b/tests/baselines/reference/keyofAndIndexedAccess.js index f7d5663bc10..05658d50515 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.js +++ b/tests/baselines/reference/keyofAndIndexedAccess.js @@ -464,6 +464,16 @@ function addToMyThingy(key: S) { MyThingy[key].push("a"); } +// Repro from #13102 + +type Handler = { + onChange: (name: keyof T) => void; +}; + +function onChangeGenericFunction(handler: Handler) { + handler.onChange('preset') +} + // Repro from #13285 function updateIds, K extends string>( @@ -801,6 +811,9 @@ var MyThingy; function addToMyThingy(key) { MyThingy[key].push("a"); } +function onChangeGenericFunction(handler) { + handler.onChange('preset'); +} // Repro from #13285 function updateIds(obj, idFields, idMapping) { for (var _i = 0, idFields_1 = idFields; _i < idFields_1.length; _i++) { @@ -1034,6 +1047,12 @@ declare let MyThingy: { [key in KeyTypes]: string[]; }; declare function addToMyThingy(key: S): void; +declare type Handler = { + onChange: (name: keyof T) => void; +}; +declare function onChangeGenericFunction(handler: Handler): void; declare function updateIds, K extends string>(obj: T, idFields: K[], idMapping: { [oldId: string]: string; }): Record; diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index a6eb03dd6e5..d7bc419af24 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -1699,83 +1699,110 @@ function addToMyThingy(key: S) { >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) } +// Repro from #13102 + +type Handler = { +>Handler : Symbol(Handler, Decl(keyofAndIndexedAccess.ts, 463, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 13)) + + onChange: (name: keyof T) => void; +>onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 468, 15)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 13)) + +}; + +function onChangeGenericFunction(handler: Handler) { +>onChangeGenericFunction : Symbol(onChangeGenericFunction, Decl(keyofAndIndexedAccess.ts, 469, 2)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 471, 33)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 471, 36)) +>Handler : Symbol(Handler, Decl(keyofAndIndexedAccess.ts, 463, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 471, 33)) +>preset : Symbol(preset, Decl(keyofAndIndexedAccess.ts, 471, 58)) + + handler.onChange('preset') +>handler.onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 471, 36)) +>onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +} + // Repro from #13285 function updateIds, K extends string>( ->updateIds : Symbol(updateIds, Decl(keyofAndIndexedAccess.ts, 463, 1)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>updateIds : Symbol(updateIds, Decl(keyofAndIndexedAccess.ts, 473, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 477, 19)) >Record : Symbol(Record, Decl(lib.d.ts, --, --)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) obj: T, ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 477, 19)) idFields: K[], ->idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 468, 11)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47)) +>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 478, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) idMapping: { [oldId: string]: string } ->idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 469, 18)) ->oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 470, 18)) +>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 479, 18)) +>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 480, 18)) ): Record { >Record : Symbol(Record, Decl(lib.d.ts, --, --)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 467, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) for (const idField of idFields) { ->idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14)) ->idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 468, 11)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) +>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 478, 11)) const newId = idMapping[obj[idField]]; ->newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13)) ->idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 469, 18)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66)) ->idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14)) +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) +>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 479, 18)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) if (newId) { ->newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13)) +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) obj[idField] = newId; ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66)) ->idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 472, 14)) ->newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 473, 13)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) } } return obj; ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 467, 66)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) } // Repro from #13285 function updateIds2( ->updateIds2 : Symbol(updateIds2, Decl(keyofAndIndexedAccess.ts, 479, 1)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20)) ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 483, 33)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 483, 54)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20)) +>updateIds2 : Symbol(updateIds2, Decl(keyofAndIndexedAccess.ts, 489, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 493, 33)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 493, 54)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) obj: T, ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 483, 74)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 483, 20)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 493, 74)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) key: K, ->key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 484, 11)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 483, 54)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 494, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 493, 54)) stringMap: { [oldId: string]: string } ->stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 485, 11)) ->oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 486, 18)) +>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 495, 11)) +>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 496, 18)) ) { var x = obj[key]; ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 488, 7)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 483, 74)) ->key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 484, 11)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 498, 7)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 493, 74)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 494, 11)) stringMap[x]; // Should be OK. ->stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 485, 11)) ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 488, 7)) +>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 495, 11)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 498, 7)) } diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 920758c8beb..543c39b3c92 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -2013,6 +2013,35 @@ function addToMyThingy(key: S) { >"a" : "a" } +// Repro from #13102 + +type Handler = { +>Handler : Handler +>T : T + + onChange: (name: keyof T) => void; +>onChange : (name: keyof T) => void +>name : keyof T +>T : T + +}; + +function onChangeGenericFunction(handler: Handler) { +>onChangeGenericFunction : (handler: Handler) => void +>T : T +>handler : Handler +>Handler : Handler +>T : T +>preset : number + + handler.onChange('preset') +>handler.onChange('preset') : void +>handler.onChange : (name: keyof (T & { preset: number; })) => void +>handler : Handler +>onChange : (name: keyof (T & { preset: number; })) => void +>'preset' : "preset" +} + // Repro from #13285 function updateIds, K extends string>( diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts index 770dc2ead98..27e47da177c 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts @@ -465,6 +465,16 @@ function addToMyThingy(key: S) { MyThingy[key].push("a"); } +// Repro from #13102 + +type Handler = { + onChange: (name: keyof T) => void; +}; + +function onChangeGenericFunction(handler: Handler) { + handler.onChange('preset') +} + // Repro from #13285 function updateIds, K extends string>( From c897235364f8d16a861669746bc298532a59bf03 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Wed, 11 Jan 2017 14:30:37 -0800 Subject: [PATCH 093/175] Change the module specifier search order --- src/services/codefixes/importFixes.ts | 4 ++-- .../importNameCodeFixNewImportTypeRoots1.ts | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 3627d60492d..8c6222ff845 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -420,10 +420,10 @@ namespace ts.codefix { const options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule(): string { diff --git a/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts new file mode 100644 index 00000000000..2778f51bacf --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts @@ -0,0 +1,23 @@ +/// + +// @Filename: a/f1.ts +//// [|foo/*0*/();|] + +// @Filename: types/random/index.ts +//// export function foo() {}; + +// @Filename: tsconfig.json +//// { +//// "compilerOptions": { +//// "baseUrl": ".", +//// "typeRoots": [ +//// "./types" +//// ] +//// } +//// } + +verify.importFixAtPosition([ +`import { foo } from "random"; + +foo();` +]); \ No newline at end of file From 9ed5ad1c2d7a9c8d7afe05ec71ff5205fb388131 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 11 Jan 2017 16:10:59 -0800 Subject: [PATCH 094/175] Unconstrained type parameter not assignable to non-primitive object --- src/compiler/checker.ts | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cc4afc8aa3e..e92ea973f8f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7172,8 +7172,7 @@ namespace ts { if (source.flags & TypeFlags.Enum && target.flags & TypeFlags.Enum && isEnumTypeRelatedTo(source, target, errorReporter)) return true; if (source.flags & TypeFlags.Undefined && (!strictNullChecks || target.flags & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true; - if (source.flags & TypeFlags.Object && target === nonPrimitiveType) return true; - if (source.flags & TypeFlags.Primitive && target === nonPrimitiveType) return false; + if (source.flags & TypeFlags.Object && target.flags & TypeFlags.NonPrimitive) return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & TypeFlags.Any) return true; if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true; @@ -7457,19 +7456,19 @@ namespace ts { } else { let constraint = getConstraintOfTypeParameter(source); - - if (!constraint || constraint.flags & TypeFlags.Any) { - constraint = emptyObjectType; - } - - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - - // Report constraint errors only if the constraint is not the empty object type - const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & TypeFlags.NonPrimitive)) { + if (!constraint || constraint.flags & TypeFlags.Any) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type + const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } @@ -9237,9 +9236,6 @@ namespace ts { } function getTypeFacts(type: Type): TypeFacts { - if (type === nonPrimitiveType) { - return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; - } const flags = type.flags; if (flags & TypeFlags.String) { return strictNullChecks ? TypeFacts.StringStrictFacts : TypeFacts.StringFacts; @@ -9280,6 +9276,9 @@ namespace ts { if (flags & TypeFlags.ESSymbol) { return strictNullChecks ? TypeFacts.SymbolStrictFacts : TypeFacts.SymbolFacts; } + if (flags & TypeFlags.NonPrimitive) { + return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; + } if (flags & TypeFlags.TypeParameter) { const constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); From 0e0953fc4fbe0220ba9c2ddf70b7ce0787dfa21a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 11 Jan 2017 16:11:16 -0800 Subject: [PATCH 095/175] Add tests --- .../types/nonPrimitive/nonPrimitiveInGeneric.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts index a19271a59d3..836896b5a57 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts @@ -1,4 +1,6 @@ -function generic(t: T) {} +function generic(t: T) { + var o: object = t; // expect error +} var a = {}; var b = "42"; @@ -7,7 +9,9 @@ generic(a); generic(123); // expect error generic(b); // expect error -function bound(t: T) {} +function bound(t: T) { + var o: object = t; // ok +} bound({}); bound(a); @@ -21,6 +25,10 @@ bound2(); bound2(); // expect error bound2(); // expect error +function bound3(t: T) { + var o: object = t; // ok +} + interface Proxy {} var x: Proxy; // error @@ -29,7 +37,7 @@ var z: Proxy ; // ok interface Blah { - foo: number; + foo: number; } var u: Proxy; // ok From e90f67d48126bb8b722ccc826c8e1c2e14a0891e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 11 Jan 2017 16:11:22 -0800 Subject: [PATCH 096/175] Accept new baselines --- .../nonPrimitiveInGeneric.errors.txt | 33 ++++++++++++------- .../reference/nonPrimitiveInGeneric.js | 25 +++++++++++--- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt index 04d4ee4a1a7..ce257c87680 100644 --- a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt +++ b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt @@ -1,14 +1,19 @@ -tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(7,17): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(8,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(14,7): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(21,8): error TS2344: Type 'number' does not satisfy the constraint 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(22,8): error TS2344: Type 'string' does not satisfy the constraint 'object'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(26,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(2,9): error TS2322: Type 'T' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(9,17): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(10,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(18,7): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(19,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(25,8): error TS2344: Type 'number' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(26,8): error TS2344: Type 'string' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(34,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. -==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (7 errors) ==== - function generic(t: T) {} +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (8 errors) ==== + function generic(t: T) { + var o: object = t; // expect error + ~ +!!! error TS2322: Type 'T' is not assignable to type 'object'. + } var a = {}; var b = "42"; @@ -21,7 +26,9 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(26,14): erro ~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. - function bound(t: T) {} + function bound(t: T) { + var o: object = t; // ok + } bound({}); bound(a); @@ -43,6 +50,10 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(26,14): erro ~~~~~~ !!! error TS2344: Type 'string' does not satisfy the constraint 'object'. + function bound3(t: T) { + var o: object = t; // ok + } + interface Proxy {} var x: Proxy; // error @@ -53,7 +64,7 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(26,14): erro interface Blah { - foo: number; + foo: number; } var u: Proxy; // ok diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.js b/tests/baselines/reference/nonPrimitiveInGeneric.js index b7080e149b4..2db357c3eb5 100644 --- a/tests/baselines/reference/nonPrimitiveInGeneric.js +++ b/tests/baselines/reference/nonPrimitiveInGeneric.js @@ -1,5 +1,7 @@ //// [nonPrimitiveInGeneric.ts] -function generic(t: T) {} +function generic(t: T) { + var o: object = t; // expect error +} var a = {}; var b = "42"; @@ -8,7 +10,9 @@ generic(a); generic(123); // expect error generic(b); // expect error -function bound(t: T) {} +function bound(t: T) { + var o: object = t; // ok +} bound({}); bound(a); @@ -22,6 +26,10 @@ bound2(); bound2(); // expect error bound2(); // expect error +function bound3(t: T) { + var o: object = t; // ok +} + interface Proxy {} var x: Proxy; // error @@ -30,21 +38,25 @@ var z: Proxy ; // ok interface Blah { - foo: number; + foo: number; } var u: Proxy; // ok //// [nonPrimitiveInGeneric.js] -function generic(t) { } +function generic(t) { + var o = t; // expect error +} var a = {}; var b = "42"; generic({}); generic(a); generic(123); // expect error generic(b); // expect error -function bound(t) { } +function bound(t) { + var o = t; // ok +} bound({}); bound(a); bound(123); // expect error @@ -54,6 +66,9 @@ bound2(); bound2(); bound2(); // expect error bound2(); // expect error +function bound3(t) { + var o = t; // ok +} var x; // error var y; // ok var z; // ok From 890676a5d8f9f5c76057ab4556bf7cc7e8ebf2df Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 11 Jan 2017 14:28:22 -0800 Subject: [PATCH 097/175] Include properties of an `export =` value in import completions. --- src/compiler/checker.ts | 1 + src/compiler/types.ts | 1 + src/harness/fourslash.ts | 28 +++++++++++++++++-- src/services/completions.ts | 6 ++++ .../completionListForExportEquals.ts | 16 +++++++++++ .../completionListForExportEquals2.ts | 14 ++++++++++ .../completionListInImportClause04.ts | 5 +--- tests/cases/fourslash/fourslash.ts | 1 + 8 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 tests/cases/fourslash/completionListForExportEquals.ts create mode 100644 tests/cases/fourslash/completionListForExportEquals2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cc4afc8aa3e..46a381a561e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -108,6 +108,7 @@ namespace ts { getAliasedSymbol: resolveAlias, getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + resolveExternalModuleSymbol, getAmbientModules, getJsxElementAttributesType, getJsxIntrinsicTagNames, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 954ad21ba29..8b3b821a25b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2370,6 +2370,7 @@ namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + /* @internal */ resolveExternalModuleSymbol(moduleSymbol: Symbol): Symbol; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c41c9af9f4e..f0f2f87175e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -425,8 +425,7 @@ namespace FourSlash { } private raiseError(message: string) { - message = this.messageAtLastKnownMarker(message); - throw new Error(message); + throw new Error(this.messageAtLastKnownMarker(message)); } private messageAtLastKnownMarker(message: string) { @@ -723,6 +722,27 @@ namespace FourSlash { } } + public verifyCompletionsAt(markerName: string, expected: string[]) { + this.goToMarker(markerName); + + const actualCompletions = this.getCompletionListAtCaret(); + if (!actualCompletions) { + this.raiseError(`No completions at position '${this.currentCaretPosition}'.`); + } + + const actual = actualCompletions.entries; + + if (actual.length !== expected.length) { + this.raiseError(`Expected ${expected.length} completions, got ${actual.map(a => a.name)}.`); + } + + ts.zipWith(actual, expected, (completion, expectedCompletion, index) => { + if (completion.name !== expectedCompletion) { + this.raiseError(`Expected completion at index ${index} to be ${expectedCompletion}, got ${completion.name}`); + } + }); + } + public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { const completions = this.getCompletionListAtCaret(); if (completions) { @@ -3166,6 +3186,10 @@ namespace FourSlashInterface { super(state); } + public completionsAt(markerName: string, completions: string[]) { + this.state.verifyCompletionsAt(markerName, completions); + } + public quickInfoIs(expectedText: string, expectedDocumentation?: string) { this.state.verifyQuickInfoString(expectedText, expectedDocumentation); } diff --git a/src/services/completions.ts b/src/services/completions.ts index d893e7212ec..27cd78bbe17 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1322,6 +1322,12 @@ namespace ts.Completions { const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); if (moduleSpecifierSymbol) { exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + const exportEquals = typeChecker.resolveExternalModuleSymbol(moduleSpecifierSymbol); + if (exportEquals !== moduleSpecifierSymbol) { + // Location doesn't matter so long as it's not an identifier. + const exportEqualsType = typeChecker.getTypeOfSymbolAtLocation(exportEquals, moduleSpecifier); + exports = ts.concatenate(exports, typeChecker.getPropertiesOfType(exportEqualsType)); + } } symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; diff --git a/tests/cases/fourslash/completionListForExportEquals.ts b/tests/cases/fourslash/completionListForExportEquals.ts new file mode 100644 index 00000000000..28b20177c57 --- /dev/null +++ b/tests/cases/fourslash/completionListForExportEquals.ts @@ -0,0 +1,16 @@ + +/// + +// @Filename: /node_modules/foo/index.d.ts +////export = Foo; +////declare var Foo: Foo.Static; +////declare namespace Foo { +//// interface Static { +//// foo(): void; +//// } +////} + +// @Filename: /a.ts +////import { /**/ } from "foo"; + +verify.completionsAt("", ["Static", "foo"]); diff --git a/tests/cases/fourslash/completionListForExportEquals2.ts b/tests/cases/fourslash/completionListForExportEquals2.ts new file mode 100644 index 00000000000..a7b0772d55e --- /dev/null +++ b/tests/cases/fourslash/completionListForExportEquals2.ts @@ -0,0 +1,14 @@ + +/// + +// @Filename: /node_modules/foo/index.d.ts +////export = Foo; +////interface Foo { bar: number; } +////declare namespace Foo { +//// interface Static {} +////} + +// @Filename: /a.ts +////import { /**/ } from "foo"; + +verify.completionsAt("", ["Static"]); diff --git a/tests/cases/fourslash/completionListInImportClause04.ts b/tests/cases/fourslash/completionListInImportClause04.ts index 672c754e807..fa49b57c8d7 100644 --- a/tests/cases/fourslash/completionListInImportClause04.ts +++ b/tests/cases/fourslash/completionListInImportClause04.ts @@ -11,10 +11,7 @@ // @Filename: app.ts ////import {/*1*/} from './foo'; -goTo.marker('1'); -verify.completionListContains('prop1'); -verify.completionListContains('prop2'); -verify.not.completionListContains('Foo'); +verify.completionsAt("1", ["prototype", "prop1", "prop2"]); verify.numberOfErrorsInCurrentFile(0); goTo.marker('2'); verify.numberOfErrorsInCurrentFile(0); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 4397839fbe8..0de303238f1 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -138,6 +138,7 @@ declare namespace FourSlashInterface { class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; caretAtMarker(markerName?: string): void; + completionsAt(markerName: string, completions: string[]): void; indentationIs(numberOfSpaces: number): void; indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle, baseIndentSize?: number): void; textAtCaretIs(text: string): void; From 733111a931d4fc65bd8e624215dc6f1ef37af9cb Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 12 Jan 2017 07:46:55 -0800 Subject: [PATCH 098/175] Use tsconfig inheritance --- src/compiler/tsconfig.json | 10 +--------- src/harness/tsconfig.json | 13 +++---------- src/server/cancellationToken/tsconfig.json | 12 ++---------- src/server/tsconfig.json | 12 ++---------- src/server/typingsInstaller/tsconfig.json | 12 ++---------- src/services/tsconfig.json | 10 +--------- src/tsconfig-base.json | 14 ++++++++++++++ 7 files changed, 25 insertions(+), 58 deletions(-) create mode 100644 src/tsconfig-base.json diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index cbbdbb04d50..1ed009444b1 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -1,17 +1,9 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/tsc.js", - "sourceMap": true, "declaration": true, - "stripInternal": true, - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true, "types": [ ] }, "files": [ diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 6b83cf249a7..ebd07118cc5 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -1,19 +1,12 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "pretty": true, "removeComments": false, - "preserveConstEnums": true, "outFile": "../../built/local/run.js", - "sourceMap": true, "declaration": false, - "stripInternal": true, "types": [ "node", "mocha", "chai" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "../compiler/core.ts", @@ -85,7 +78,7 @@ "../services/codefixes/importFixes.ts", "../services/codefixes/unusedIdentifierFixes.ts", "../services/harness.ts", - + "sourceMapRecorder.ts", "harnessLanguageService.ts", "fourslash.ts", diff --git a/src/server/cancellationToken/tsconfig.json b/src/server/cancellationToken/tsconfig.json index 1c4c0d60826..fa7f88ca994 100644 --- a/src/server/cancellationToken/tsconfig.json +++ b/src/server/cancellationToken/tsconfig.json @@ -1,19 +1,11 @@ { + "extends": "../../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "module": "commonjs", - "sourceMap": true, - "stripInternal": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "cancellationToken.ts" diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 85c88679164..2f17019e2de 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -1,19 +1,11 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/tsserver.js", - "sourceMap": true, - "stripInternal": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "../services/shims.ts", diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index 27f5cedc9d1..7bfb6c8b1ed 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -1,19 +1,11 @@ { + "extends": "../../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../../built/local/typingsInstaller.js", - "sourceMap": true, - "stripInternal": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "../types.ts", diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 921ee7762f8..e79716d2c67 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -1,18 +1,10 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": false, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/typescriptServices.js", - "sourceMap": true, - "stripInternal": true, "noResolve": false, "declaration": true, - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true, "types": [] }, "files": [ diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json new file mode 100644 index 00000000000..d3fcf8f1520 --- /dev/null +++ b/src/tsconfig-base.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "lib": ["es5"], + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true, + "preserveConstEnums": true, + "stripInternal": true, + "sourceMap": true, + "target": "es5" + } +} \ No newline at end of file From 30e2fd6c2043b1ee407bb503529a3b0c219b1501 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 12 Jan 2017 10:18:59 -0800 Subject: [PATCH 099/175] Remove "noResolve" --- src/services/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index e79716d2c67..13686d232a1 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -3,7 +3,6 @@ "compilerOptions": { "removeComments": false, "outFile": "../../built/local/typescriptServices.js", - "noResolve": false, "declaration": true, "types": [] }, From bf7258742eccd1691c139417715e3eb5e7d18d54 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 12 Jan 2017 10:49:44 -0800 Subject: [PATCH 100/175] Improve type relationships for generic mapped types --- src/compiler/checker.ts | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cc4afc8aa3e..d8456b8074c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4662,10 +4662,6 @@ namespace ts { return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type: MappedType) { - return instantiateType(getTemplateTypeFromMappedType(type), createTypeEraser([getTypeParameterFromMappedType(type)])); - } - function isGenericMappedType(type: Type) { if (getObjectFlags(type) & ObjectFlags.Mapped) { const constraintType = getConstraintTypeFromMappedType(type); @@ -7765,25 +7761,24 @@ namespace ts { return result; } - // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is + // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice + // that S and T are contra-variant whereas X and Y are co-variant. function mappedTypeRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - let result: Ternary; - if (relation === identityRelation) { - const readonlyMatches = !(source).declaration.readonlyToken === !(target).declaration.readonlyToken; - const optionalMatches = !(source).declaration.questionToken === !(target).declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !(source).declaration.questionToken || (target).declaration.questionToken) { - if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + const sourceReadonly = !!(source).declaration.readonlyToken; + const sourceOptional = !!(source).declaration.questionToken; + const targetReadonly = !!(target).declaration.readonlyToken; + const targetOptional = !!(target).declaration.questionToken; + const modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + let result: Ternary; + if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + const mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } From dafea7f54d46cf7715cffa466649e48d51684c54 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 12 Jan 2017 10:49:58 -0800 Subject: [PATCH 101/175] Add tests --- .../types/mapped/mappedTypeRelationships.ts | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts b/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts index 4af71fbea08..587ec1c9d7e 100644 --- a/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts +++ b/tests/cases/conformance/types/mapped/mappedTypeRelationships.ts @@ -105,4 +105,66 @@ function f50(obj: T, key: keyof T) { function f51(obj: T, key: K) { let item: Item = obj[key]; return obj[key].name; -} \ No newline at end of file +} + +type T1 = { + [P in keyof T]: T[P]; +} + +type T2 = { + [P in keyof T]: T[P]; +} + +function f60(x: T1, y: T2) { + x = y; + y = x; +} + +type Identity = { + [P in keyof T]: T[P]; +} + +function f61(x: Identity, y: Partial) { + x = y; // Error + y = x; +} + +function f62(x: Identity, y: Readonly) { + x = y; + y = x; +} + +function f70(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; +} + +function f71(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f73(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; // Error +} + +function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { + x = y; + y = x; // Error +} From 1f8b9f8bbeab6a244bfcb5fa292bf4261a196b20 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 12 Jan 2017 10:50:08 -0800 Subject: [PATCH 102/175] Accept new baselines --- .../mappedTypeRelationships.errors.txt | 104 +++++++++++- .../reference/mappedTypeRelationships.js | 152 +++++++++++++++++- 2 files changed, 253 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index ce6ecaa61fa..22f56dacaf6 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -30,9 +30,24 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(62,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(67,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(71,5): error TS2322: Type 'Partial' is not assignable to type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2322: Type 'Partial' is not assignable to type 'T'. +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'. +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]; }'. + Type 'keyof T' is not assignable to type 'K'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(157,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. + Type 'keyof U' is not assignable to type 'K'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(162,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. + 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'. -==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (20 errors) ==== +==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (27 errors) ==== function f1(x: T, k: keyof T) { return x[k]; @@ -190,4 +205,89 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 function f51(obj: T, key: K) { let item: Item = obj[key]; return obj[key].name; - } \ No newline at end of file + } + + type T1 = { + [P in keyof T]: T[P]; + } + + type T2 = { + [P in keyof T]: T[P]; + } + + function f60(x: T1, y: T2) { + x = y; + y = x; + } + + type Identity = { + [P in keyof T]: T[P]; + } + + function f61(x: Identity, y: Partial) { + x = y; // Error + ~ +!!! error TS2322: Type 'Partial' is not assignable to type 'Identity'. + y = x; + } + + function f62(x: Identity, y: Readonly) { + x = y; + y = x; + } + + function f70(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; + } + + function f71(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! 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'. + } + + function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. +!!! error TS2322: Type 'keyof U' is not assignable to type 'keyof T'. + } + + function f73(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'K'. + } + + function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. +!!! error TS2322: Type 'keyof U' is not assignable to type 'K'. + } + + function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'K'. + } + + function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! 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'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeRelationships.js b/tests/baselines/reference/mappedTypeRelationships.js index a81ff973da8..2476b72cef6 100644 --- a/tests/baselines/reference/mappedTypeRelationships.js +++ b/tests/baselines/reference/mappedTypeRelationships.js @@ -104,7 +104,70 @@ function f50(obj: T, key: keyof T) { function f51(obj: T, key: K) { let item: Item = obj[key]; return obj[key].name; -} +} + +type T1 = { + [P in keyof T]: T[P]; +} + +type T2 = { + [P in keyof T]: T[P]; +} + +function f60(x: T1, y: T2) { + x = y; + y = x; +} + +type Identity = { + [P in keyof T]: T[P]; +} + +function f61(x: Identity, y: Partial) { + x = y; // Error + y = x; +} + +function f62(x: Identity, y: Readonly) { + x = y; + y = x; +} + +function f70(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; +} + +function f71(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f73(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; // Error +} + +function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { + x = y; + y = x; // Error +} + //// [mappedTypeRelationships.js] function f1(x, k) { @@ -185,6 +248,46 @@ function f51(obj, key) { var item = obj[key]; return obj[key].name; } +function f60(x, y) { + x = y; + y = x; +} +function f61(x, y) { + x = y; // Error + y = x; +} +function f62(x, y) { + x = y; + y = x; +} +function f70(x, y) { + x = y; + y = x; +} +function f71(x, y) { + x = y; + y = x; // Error +} +function f72(x, y) { + x = y; + y = x; // Error +} +function f73(x, y) { + x = y; + y = x; // Error +} +function f74(x, y) { + x = y; + y = x; // Error +} +function f75(x, y) { + x = y; + y = x; // Error +} +function f76(x, y) { + x = y; + y = x; // Error +} //// [mappedTypeRelationships.d.ts] @@ -214,3 +317,50 @@ declare type ItemMap = { }; declare function f50(obj: T, key: keyof T): string; declare function f51(obj: T, key: K): string; +declare type T1 = { + [P in keyof T]: T[P]; +}; +declare type T2 = { + [P in keyof T]: T[P]; +}; +declare function f60(x: T1, y: T2): void; +declare type Identity = { + [P in keyof T]: T[P]; +}; +declare function f61(x: Identity, y: Partial): void; +declare function f62(x: Identity, y: Readonly): void; +declare function f70(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof T]: T[P]; +}): void; +declare function f71(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof T]: U[P]; +}): void; +declare function f72(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof U]: U[P]; +}): void; +declare function f73(x: { + [P in K]: T[P]; +}, y: { + [P in keyof T]: T[P]; +}): void; +declare function f74(x: { + [P in K]: T[P]; +}, y: { + [P in keyof U]: U[P]; +}): void; +declare function f75(x: { + [P in K]: T[P]; +}, y: { + [P in keyof T]: U[P]; +}): void; +declare function f76(x: { + [P in K]: T[P]; +}, y: { + [P in K]: U[P]; +}): void; From b98e82e5c4f1172309546e51d9b871aa2e0c1dc7 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 12 Jan 2017 12:25:00 -0800 Subject: [PATCH 103/175] Fix one more use of `createMapFromTemplate` --- src/server/typingsInstaller/nodeTypingsInstaller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 19f794ad57c..ff20e89e2d7 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -46,7 +46,7 @@ namespace ts.server.typingsInstaller { } try { const content = JSON.parse(host.readFile(typesRegistryFilePath)); - return createMap(content.entries); + return createMapFromTemplate(content.entries); } catch (e) { if (log.isEnabled()) { From 757af2e1d6ae10666aa1f26cb7efdc59e01884d5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 12 Jan 2017 13:11:26 -0800 Subject: [PATCH 104/175] Fix tsconfig inheritance in gulpfile -- must do it manually --- Gulpfile.ts | 14 ++++++-------- src/compiler/sys.ts | 2 +- src/tsconfig-base.json | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index ef65454bc23..2daa8970582 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -242,13 +242,14 @@ function needsUpdate(source: string | string[], dest: string | string[]): boolea return true; } +// Doing tsconfig inheritance manually. https://github.com/ivogabe/gulp-typescript/issues/459 +const tsconfigBase = JSON.parse(fs.readFileSync("src/tsconfig-base.json", "utf-8")).compilerOptions; + function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): tsc.Settings { const copy: tsc.Settings = {}; - copy.noEmitOnError = true; - copy.noImplicitAny = true; - copy.noImplicitThis = true; - copy.pretty = true; - copy.types = []; + for (const key in tsconfigBase) { + copy[key] = tsconfigBase[key]; + } for (const key in base) { copy[key] = base[key]; } @@ -256,9 +257,6 @@ function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): ts if (copy.removeComments === undefined) copy.removeComments = true; copy.newLine = "lf"; } - else { - copy.preserveConstEnums = true; - } if (useBuiltCompiler === true) { copy.typescript = require("./built/local/typescript.js"); } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 8e140375dd0..966f0e0cd03 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -18,7 +18,7 @@ namespace ts { getFileSize?(path: string): number; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; /** - * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that + * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that * use native OS file watching */ watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index d3fcf8f1520..b4c82dbeeee 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "lib": ["es5"], + "noEmitOnError": true, "noImplicitAny": true, "noImplicitThis": true, "noUnusedLocals": true, From 6b6c34bef14ff50733c479b52cdb4b27c20c981d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 12 Jan 2017 13:56:45 -0800 Subject: [PATCH 105/175] Fix typo --- src/compiler/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 02cc2b4a453..654b1bc2912 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -895,7 +895,7 @@ namespace ts { return undefined; } - /** `forEachInMap` for just keys. */ + /** `forEachEntry` for just keys. */ export function forEachKey(map: Map<{}>, callback: (key: string) => T | undefined): T | undefined { const iterator = map.keys(); for (let { value: key, done } = iterator.next(); !done; { value: key, done } = iterator.next()) { From b40613c4d7436c953351e4192a06d07874374470 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 12 Jan 2017 14:01:04 -0800 Subject: [PATCH 106/175] Stop using "dom" types --- Jakefile.js | 4 ++-- src/compiler/sys.ts | 3 +++ src/tsconfig-base.json | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index a786fb16ed3..3ee8476c842 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -456,7 +456,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --stripInternal"; } - options += " --target es5 --noUnusedLocals --noUnusedParameters"; + options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters"; var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); @@ -726,7 +726,7 @@ compileFile( // Appending exports at the end of the server library var tsserverLibraryDefinitionFileContents = - fs.readFileSync(tsserverLibraryDefinitionFile).toString() + + fs.readFileSync(tsserverLibraryDefinitionFile).toString() + "\r\nexport = ts;" + "\r\nexport as namespace ts;"; diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 966f0e0cd03..08dc4b6d81f 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,5 +1,8 @@ /// +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; +declare function clearTimeout(handle: any): void; + namespace ts { export type FileWatcherCallback = (fileName: string, removed?: boolean) => void; export type DirectoryWatcherCallback = (fileName: string) => void; diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index b4c82dbeeee..7c67f49d1e5 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "lib": ["es5", "scripthost"], "noEmitOnError": true, "noImplicitAny": true, "noImplicitThis": true, From d630980f793f381b9c8d43c15ef417d82feca588 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 12 Jan 2017 14:25:24 -0800 Subject: [PATCH 107/175] Add dom declarations used by harness --- src/harness/harness.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 4094fc773ea..7bd9f0f316a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -40,8 +40,22 @@ declare namespace NodeJS { ActiveXObject: typeof ActiveXObject; } } + +declare var window: {}; +declare var XMLHttpRequest: { + new(): XMLHttpRequest; +} +interface XMLHttpRequest { + readonly readyState: number; + readonly responseText: string; + readonly status: number; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + send(data?: string): void; + setRequestHeader(header: string, value: string): void; +} /* tslint:enable:no-var-keyword */ + namespace Utils { // Setup some globals based on the current environment export const enum ExecutionEnvironment { From 765114fccd08440a2676da74ee76229f571d8330 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 13 Jan 2017 07:57:01 -0800 Subject: [PATCH 108/175] Refactor to move code into checker --- src/compiler/checker.ts | 11 ++++++++++- src/compiler/types.ts | 3 ++- src/services/completions.ts | 18 ++++++------------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 46a381a561e..a5d1e439879 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -108,7 +108,7 @@ namespace ts { getAliasedSymbol: resolveAlias, getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, - resolveExternalModuleSymbol, + getExportsAndPropertiesOfModule, getAmbientModules, getJsxElementAttributesType, getJsxIntrinsicTagNames, @@ -1528,6 +1528,15 @@ namespace ts { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[] { + const exports = getExportsOfModuleAsArray(moduleSymbol); + const exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } + function tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined { const symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8b3b821a25b..0906488ea33 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2370,7 +2370,8 @@ namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - /* @internal */ resolveExternalModuleSymbol(moduleSymbol: Symbol): Symbol; + /** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */ + /* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[]; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; diff --git a/src/services/completions.ts b/src/services/completions.ts index 27cd78bbe17..bb5922af9ad 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1318,20 +1318,14 @@ namespace ts.Completions { isMemberCompletion = true; isNewIdentifierLocation = false; - let exports: Symbol[]; - const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - const exportEquals = typeChecker.resolveExternalModuleSymbol(moduleSpecifierSymbol); - if (exportEquals !== moduleSpecifierSymbol) { - // Location doesn't matter so long as it's not an identifier. - const exportEqualsType = typeChecker.getTypeOfSymbolAtLocation(exportEquals, moduleSpecifier); - exports = ts.concatenate(exports, typeChecker.getPropertiesOfType(exportEqualsType)); - } + const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; - + const exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } From 639f5cb6e5f8ae61eee1ca9828ad14c6ea43ada5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 13 Jan 2017 08:10:58 -0800 Subject: [PATCH 109/175] Fix bug for constructor with modifier --- src/services/findAllReferences.ts | 5 ++--- src/services/utilities.ts | 2 +- .../fourslash/findAllRefsOfConstructor_withModifier.ts | 10 ++++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index d6092644c73..287c16d5e7e 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -502,9 +502,8 @@ namespace ts.FindAllReferences { const result: Node[] = []; for (const decl of classSymbol.members["__constructor"].declarations) { - Debug.assert(decl.kind === SyntaxKind.Constructor); - const ctrKeyword = decl.getChildAt(0); - Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword); + const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)! + Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); result.push(ctrKeyword); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 47608a59e75..def7ab8e4bd 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -600,7 +600,7 @@ namespace ts { return !!findChildOfKind(n, kind, sourceFile); } - export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node { + export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node | undefined { return forEach(n.getChildren(sourceFile), c => c.kind === kind && c); } diff --git a/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts b/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts new file mode 100644 index 00000000000..0954945a546 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts @@ -0,0 +1,10 @@ +/// + +////class X { +//// public [|constructor|]() {} +////} +////var x = new [|X|](); + +const ranges = test.ranges(); +const ctr = ranges[0]; +verify.referencesOf(ctr, ranges); From ebf36ac06bee8029f0183a5dc3f529a8281f20ba Mon Sep 17 00:00:00 2001 From: MANISH-GIRI Date: Fri, 13 Jan 2017 12:53:21 -0500 Subject: [PATCH 110/175] Fix incorrect return type --- src/compiler/scanner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index a03bf733f75..da7308ecb89 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -734,11 +734,11 @@ namespace ts { return comments; } - export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] { + export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined { return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] { + export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined { return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); } From 0b8de64a1b74728f28e4abb1eebdbac6bc877b0a Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 13 Jan 2017 13:16:14 -0800 Subject: [PATCH 111/175] Move code out of closure in `getReferencedSymbolsForNode` --- src/services/findAllReferences.ts | 2091 +++++++++---------- tests/cases/fourslash/findAllRefsForRest.ts | 5 +- 2 files changed, 1046 insertions(+), 1050 deletions(-) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 287c16d5e7e..cf502ad50f9 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -30,20 +30,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) : undefined; + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); } else { // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node); + return getLabelReferencesInNode(node.parent, node, cancellationToken); } } if (isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); } if (node.kind === SyntaxKind.SuperKeyword) { - return getReferencesForSuperKeyword(node); + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); } } @@ -52,10 +52,9 @@ namespace ts.FindAllReferences { const symbol = typeChecker.getSymbolAtLocation(node); if (!implementations && !symbol && node.kind === SyntaxKind.StringLiteral) { - return getReferencesForStringLiteral(node, sourceFiles); + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); } - // Could not find a symbol e.g. unknown identifier if (!symbol) { // Can't have references to something that we have no symbol for. @@ -87,7 +86,7 @@ namespace ts.FindAllReferences { if (scope) { result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken); } else { const internedName = getInternedName(symbol, node); @@ -98,1158 +97,1156 @@ namespace ts.FindAllReferences { if (nameTable[internedName] !== undefined) { result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken); } } } return result; + } - function getDefinition(symbol: Symbol): ReferencedSymbolDefinitionInfo { - const info = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node); - const name = map(info.displayParts, p => p.text).join(""); - const declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - - return { - containerKind: "", - containerName: "", - name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts - }; - } - - function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol | undefined { - if (symbol.flags & SymbolFlags.Alias) { - // Default import get alias - const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - - const importOrExportSpecifier = forEach(symbol.declarations, - declaration => (declaration.kind === SyntaxKind.ImportSpecifier || - declaration.kind === SyntaxKind.ExportSpecifier) ? declaration : undefined); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === SyntaxKind.ImportSpecifier ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } - } + function getDefinition(symbol: Symbol, node: Node, typeChecker: TypeChecker): ReferencedSymbolDefinitionInfo { + const info = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node); + const name = map(info.displayParts, p => p.text).join(""); + const declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol: Symbol, location: Node): Symbol { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } + return { + containerKind: "", + containerName: "", + name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: createTextSpan(declarations[0].getStart(), 0), + displayParts: info.displayParts + }; + } - function getPropertySymbolOfDestructuringAssignment(location: Node) { - return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } + function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node, typeChecker: TypeChecker): Symbol | undefined { + if (symbol.flags & SymbolFlags.Alias) { + // Default import get alias + const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); + } - function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol) { + const importOrExportSpecifier = forEach(symbol.declarations, + declaration => (declaration.kind === SyntaxKind.ImportSpecifier || + declaration.kind === SyntaxKind.ExportSpecifier) ? declaration : undefined); + if (importOrExportSpecifier && + // export { a } + (!importOrExportSpecifier.propertyName || + // export {a as class } where a is location + importOrExportSpecifier.propertyName === location)) { + // If Import specifier -> get alias + // else Export specifier -> get local target + return importOrExportSpecifier.kind === SyntaxKind.ImportSpecifier ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); + } + } + return undefined; + } + + function followAliasIfNecessary(symbol: Symbol, location: Node, typeChecker: TypeChecker): Symbol { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + + function getPropertySymbolOfDestructuringAssignment(location: Node, typeChecker: TypeChecker) { + return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + + function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol) { + const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); + return bindingElement && + bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern && + !bindingElement.propertyName; + } + + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, typeChecker: TypeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); - return bindingElement && - bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern && - !bindingElement.propertyName; + const typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, (bindingElement.name).text); + } + return undefined; + } + + function getInternedName(symbol: Symbol, location: Node): string { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); - const typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, (bindingElement.name).text); + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + const localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + + return stripQuotes(symbol.name); + } + + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ + function getSymbolScope(symbol: Symbol): Node { + // If this is the symbol of a named function expression or named class expression, + // then named references are limited to its own scope. + const valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) { + return valueDeclaration; + } + + // If this is private property or method, the scope is the containing class + if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { + const privateDeclaration = forEach(symbol.getDeclarations(), d => (getModifierFlags(d) & ModifierFlags.Private) ? d : undefined); + if (privateDeclaration) { + return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration); } + } + + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visible outside its declaration scope. + if (symbol.flags & SymbolFlags.Alias) { return undefined; } - function getInternedName(symbol: Symbol, location: Node): string { - // If this is an export or import specifier it could have been renamed using the 'as' syntax. - // If so we want to search for whatever under the cursor. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - - // Try to get the local symbol if we're dealing with an 'export default' - // since that symbol has the "true" name. - const localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - - return stripQuotes(symbol.name); + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; } - /** - * Determines the smallest scope in which a symbol may have named references. - * Note that not every construct has been accounted for. This function can - * probably be improved. - * - * @returns undefined if the scope cannot be determined, implying that - * a reference to a symbol can occur anywhere. - */ - function getSymbolScope(symbol: Symbol): Node { - // If this is the symbol of a named function expression or named class expression, - // then named references are limited to its own scope. - const valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) { - return valueDeclaration; - } - - // If this is private property or method, the scope is the containing class - if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { - const privateDeclaration = forEach(symbol.getDeclarations(), d => (getModifierFlags(d) & ModifierFlags.Private) ? d : undefined); - if (privateDeclaration) { - return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration); - } - } - - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & SymbolFlags.Alias) { - return undefined; - } - - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - - // 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.SyntheticProperty)) { - return undefined; - } - - let scope: Node; - - const declarations = symbol.getDeclarations(); - if (declarations) { - for (const declaration of declarations) { - const container = getContainerNode(declaration); - - if (!container) { - return undefined; - } - - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - - if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { - // This is a global variable and not an external module, any declaration defined - // within this scope is visible outside the file - return undefined; - } - - // The search scope is the container node - scope = container; - } - } - - return scope; + // 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.SyntheticProperty)) { + return undefined; } - function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, start: number, end: number): number[] { - const positions: number[] = []; + let scope: Node; - /// TODO: Cache symbol existence for files to save text search - // Also, need to make this work for unicode escapes. + const declarations = symbol.getDeclarations(); + if (declarations) { + for (const declaration of declarations) { + const container = getContainerNode(declaration); - // Be resilient in the face of a symbol with no name or zero length name - if (!symbolName || !symbolName.length) { - return positions; - } - - const text = sourceFile.text; - const sourceLength = text.length; - const symbolNameLength = symbolName.length; - - let position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - - // If we are past the end, stop looking - if (position > end) break; - - // We found a match. Make sure it's not part of a larger word (i.e. the char - // before and after it have to be a non-identifier char). - const endPosition = position + symbolNameLength; - - if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && - (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) { - // Found a real match. Keep searching. - positions.push(position); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); - } + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + + if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { + // This is a global variable and not an external module, any declaration defined + // within this scope is visible outside the file + return undefined; + } + + // The search scope is the container node + scope = container; + } + } + + return scope; + } + + function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, start: number, end: number, cancellationToken: CancellationToken): number[] { + const positions: number[] = []; + + /// TODO: Cache symbol existence for files to save text search + // Also, need to make this work for unicode escapes. + + // Be resilient in the face of a symbol with no name or zero length name + if (!symbolName || !symbolName.length) { return positions; } - function getLabelReferencesInNode(container: Node, targetLabel: Identifier): ReferencedSymbol[] { - const references: ReferenceEntry[] = []; - const sourceFile = container.getSourceFile(); - const labelName = targetLabel.text; - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + const text = sourceFile.text; + const sourceLength = text.length; + const symbolNameLength = symbolName.length; + + let position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + + // If we are past the end, stop looking + if (position > end) break; + + // We found a match. Make sure it's not part of a larger word (i.e. the char + // before and after it have to be a non-identifier char). + const endPosition = position + symbolNameLength; + + if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && + (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } + + return positions; + } + + function getLabelReferencesInNode(container: Node, targetLabel: Identifier, cancellationToken: CancellationToken): ReferencedSymbol[] { + const references: ReferenceEntry[] = []; + const sourceFile = container.getSourceFile(); + const labelName = targetLabel.text; + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + forEach(possiblePositions, position => { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + + // 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)); + } + }); + + const definition: ReferencedSymbolDefinitionInfo = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)] + }; + + return [{ definition, references }]; + } + + function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case SyntaxKind.Identifier: + return node.getWidth() === searchSymbolName.length; + + case SyntaxKind.StringLiteral: + return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + + case SyntaxKind.NumericLiteral: + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + + default: + return false; + } + } + + /** Search within node "container" for references for a search value, where the search value is defined as a + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ + function getReferencesInNode(container: Node, + searchSymbol: Symbol, + searchText: string, + searchLocation: Node, + searchMeaning: SemanticMeaning, + findInStrings: boolean, + findInComments: boolean, + result: ReferencedSymbol[], + symbolToIndex: number[], + implementations: boolean, + typeChecker: TypeChecker, + cancellationToken: CancellationToken): void { + + const sourceFile = container.getSourceFile(); + + const start = findInComments ? container.getFullStart() : container.getStart(); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + + const parents = getParentSymbolsOfPropertyAccess(); + const inheritsFromCache: Map = createMap(); + + if (possiblePositions.length) { + // Build the set of symbols to search for, initially it has only the current symbol + const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation, typeChecker, implementations); + forEach(possiblePositions, position => { cancellationToken.throwIfCancellationRequested(); - const node = getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { + const referenceLocation = getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + // This wasn't the start of a token. Check to see if it might be a + // match in a comment or string if that's what the caller is asking + // for. + if (!implementations && ((findInStrings && isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position)))) { + + // In the case where we're looking inside comments/strings, we don't have + // an actual definition. So just use 'undefined' here. Features like + // 'Rename' won't care (as they ignore the definitions), and features like + // 'FindReferences' will just filter out these results. + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } return; } - // 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)); + if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { + return; + } + + const referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache, typeChecker); + + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment + * has two meaning : property name and property value. Therefore when we do findAllReference at the position where + * an identifier is declared, the language service should return the position of the variable declaration as well as + * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the + * position of property accessing, the referenceEntry of such position will be handled in the first case. + */ + else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } } }); + } + return; - const definition: ReferencedSymbolDefinitionInfo = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ScriptElementKind.label, - name: labelName, - textSpan: createTextSpanFromNode(targetLabel, sourceFile), - displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)] - }; - - return [{ definition, references }]; + /* If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess(): Symbol[] | undefined { + if (implementations) { + const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + const localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & TypeFlags.UnionOrIntersection) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } + } + } } - function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { - if (node) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node.kind) { - case SyntaxKind.Identifier: - return node.getWidth() === searchSymbolName.length; - - case SyntaxKind.StringLiteral: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - // For string literals we have two additional chars for the quotes - return node.getWidth() === searchSymbolName.length + 2; - } - break; - - case SyntaxKind.NumericLiteral: - if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; - } - break; - } - } - - return false; + function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression { + return isRightSideOfPropertyAccess(node) && node.parent; } - /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ - function getReferencesInNode(container: Node, - searchSymbol: Symbol, - searchText: string, - searchLocation: Node, - searchMeaning: SemanticMeaning, - findInStrings: boolean, - findInComments: boolean, - result: ReferencedSymbol[], - symbolToIndex: number[]): void { + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ + function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { + Debug.assert(isClassLike(searchSymbol.valueDeclaration)); - const sourceFile = container.getSourceFile(); - - const start = findInComments ? container.getFullStart() : container.getStart(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - - const parents = getParentSymbolsOfPropertyAccess(); - const inheritsFromCache: Map = createMap(); - - if (possiblePositions.length) { - // Build the set of symbols to search for, initially it has only the current symbol - const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation); - - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); - - const referenceLocation = getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a - // match in a comment or string if that's what the caller is asking - // for. - if (!implementations && ((findInStrings && isInString(sourceFile, position)) || - (findInComments && isInNonReferenceComment(sourceFile, position)))) { - - // In the case where we're looking inside comments/strings, we don't have - // an actual definition. So just use 'undefined' here. Features like - // 'Rename' won't care (as they ignore the definitions), and features like - // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - - if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - - const referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache); - - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment - * has two meaning : property name and property value. Therefore when we do findAllReference at the position where - * an identifier is declared, the language service should return the position of the variable declaration as well as - * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the - * position of property accessing, the referenceEntry of such position will be handled in the first case. - */ - else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); + const referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) { + Debug.assert(referenceClass.name === referenceLocation); + // This is the class declaration containing the constructor. + addReferences(findOwnConstructorCalls(searchSymbol)); } - return; - - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess(): Symbol[] | undefined { - if (implementations) { - const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - const localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & TypeFlags.UnionOrIntersection) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } + else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + const classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); } } + } - function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression { - return isRightSideOfPropertyAccess(node) && node.parent; + function addReferences(references: Node[]): void { + if (references.length) { + const referencedSymbol = getReferencedSymbol(searchSymbol); + addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); + } + } + + /** `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorCalls(classSymbol: Symbol): Node[] { + const result: Node[] = []; + + for (const decl of classSymbol.members["__constructor"].declarations) { + const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)! + Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); + result.push(ctrKeyword); } - /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { - Debug.assert(isClassLike(searchSymbol.valueDeclaration)); - - const referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) { - Debug.assert(referenceClass.name === referenceLocation); - // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - // If this class appears in `extends C`, then the extending class' "super" calls are references. - const classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - - function addReferences(references: Node[]): void { - if (references.length) { - const referencedSymbol = getReferencedSymbol(searchSymbol); - addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); - } - } - - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol: Symbol): Node[] { - const result: Node[] = []; - - for (const decl of classSymbol.members["__constructor"].declarations) { - const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)! - Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); - result.push(ctrKeyword); - } - - forEachProperty(classSymbol.exports, member => { - const decl = member.valueDeclaration; - if (decl && decl.kind === SyntaxKind.MethodDeclaration) { - const body = (decl).body; - if (body) { - forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { - if (isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - - return result; - } - - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] { - const symbol = cls.symbol; - const ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - - const result: Node[] = []; - for (const decl of ctr.declarations) { - Debug.assert(decl.kind === SyntaxKind.Constructor); - const body = (decl).body; + forEachProperty(classSymbol.exports, member => { + const decl = member.valueDeclaration; + if (decl && decl.kind === SyntaxKind.MethodDeclaration) { + const body = (decl).body; if (body) { - forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => { - if (isCallExpressionTarget(node)) { - result.push(node); + forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { + if (isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); } }); } - }; - return result; - } - - function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { - const symbolId = getSymbolId(symbol); - let index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - - result.push({ - definition: getDefinition(symbol), - references: [] - }); } + }); - return result[index]; - } - - function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { - const references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - - function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[]): 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)); - } - 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); - } - - // Check if the node is within an extends or implements clause - const containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - - // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface - const containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - const parent = containingTypeReference.parent; - if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(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)); - } - }); - } - else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); - } - } - else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); - } - } - } - - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // 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) { - if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { - result.push(a); - } - } - } - - function getSymbolsForClassAndInterfaceComponents(type: UnionOrIntersectionType, result: Symbol[] = []): Symbol[] { - for (const componentType of type.types) { - if (componentType.symbol && componentType.symbol.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & TypeFlags.UnionOrIntersection) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } return result; } - function getContainingTypeReference(node: Node): Node { - let topLevelTypeReference: Node = undefined; - - while (node) { - if (isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; + /** Find references to `super` in the constructor of an extending class. */ + function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] { + const symbol = cls.symbol; + const ctr = symbol.members["__constructor"]; + if (!ctr) { + return []; } - return topLevelTypeReference; + const result: Node[] = []; + for (const decl of ctr.declarations) { + Debug.assert(decl.kind === SyntaxKind.Constructor); + const body = (decl).body; + if (body) { + forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => { + if (isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + }; + return result; } - function getContainingClassIfInHeritageClause(node: Node): ClassLikeDeclaration { - if (node && node.parent) { - if (node.kind === SyntaxKind.ExpressionWithTypeArguments - && node.parent.kind === SyntaxKind.HeritageClause - && isClassLike(node.parent.parent)) { - return node.parent.parent; - } + function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { + const symbolId = getSymbolId(symbol); + let index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; - else if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression) { - return getContainingClassIfInHeritageClause(node.parent); + result.push({ + definition: getDefinition(symbol, searchLocation, typeChecker), + references: [] + }); + } + + return result[index]; + } + + function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { + const references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + + function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[], typeChecker: TypeChecker): 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)); + } + 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); + } + + // Check if the node is within an extends or implements clause + const containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + const containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + const parent = containingTypeReference.parent; + if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(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)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); } } - return undefined; } - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node: Expression): boolean { - // Unwrap parentheses - if (node.kind === SyntaxKind.ParenthesizedExpression) { + // Type nodes can contain multiple references to the same type. For example: + // let x: Foo & (Foo & Bar) = ... + // 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) { + if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { + result.push(a); + } + } + } + + function getSymbolsForClassAndInterfaceComponents(type: UnionOrIntersectionType, result: Symbol[] = []): Symbol[] { + for (const componentType of type.types) { + if (componentType.symbol && componentType.symbol.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & TypeFlags.UnionOrIntersection) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + + function getContainingTypeReference(node: Node): Node { + let topLevelTypeReference: Node = undefined; + + while (node) { + if (isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + + return topLevelTypeReference; + } + + function getContainingClassIfInHeritageClause(node: Node): ClassLikeDeclaration { + if (node && node.parent) { + if (node.kind === SyntaxKind.ExpressionWithTypeArguments + && node.parent.kind === SyntaxKind.HeritageClause + && isClassLike(node.parent.parent)) { + return node.parent.parent; + } + + else if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node: Expression): boolean { + switch (node.kind) { + case SyntaxKind.ParenthesizedExpression: return isImplementationExpression((node).expression); + case SyntaxKind.ArrowFunction: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.ClassExpression: + case SyntaxKind.ArrayLiteralExpression: + return true; + default: + return false; + } + } + + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child: Symbol, parent: Symbol, cachedResults: Map, typeChecker: TypeChecker): boolean { + const parentIsInterface = parent.getFlags() & SymbolFlags.Interface; + return searchHierarchy(child); + + function searchHierarchy(symbol: Symbol): boolean { + if (symbol === parent) { + return true; } - return node.kind === SyntaxKind.ArrowFunction || - node.kind === SyntaxKind.FunctionExpression || - node.kind === SyntaxKind.ObjectLiteralExpression || - node.kind === SyntaxKind.ClassExpression || - node.kind === SyntaxKind.ArrayLiteralExpression; - } + const key = getSymbolId(symbol) + "," + getSymbolId(parent); + if (key in cachedResults) { + return cachedResults[key]; + } - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child: Symbol, parent: Symbol, cachedResults: Map): boolean { - const parentIsInterface = parent.getFlags() & SymbolFlags.Interface; - return searchHierarchy(child); + // Set the key so that we don't infinitely recurse + cachedResults[key] = false; - function searchHierarchy(symbol: Symbol): boolean { - if (symbol === parent) { - return true; - } - - const key = getSymbolId(symbol) + "," + getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - - // Set the key so that we don't infinitely recurse - cachedResults[key] = false; - - const inherits = forEach(symbol.getDeclarations(), declaration => { - if (isClassLike(declaration)) { - if (parentIsInterface) { - const interfaceReferences = getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (const typeReference of interfaceReferences) { - if (searchTypeReference(typeReference)) { - return true; - } + const inherits = forEach(symbol.getDeclarations(), declaration => { + if (isClassLike(declaration)) { + if (parentIsInterface) { + const interfaceReferences = getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (const typeReference of interfaceReferences) { + if (searchTypeReference(typeReference)) { + return true; } } } - return searchTypeReference(getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { - if (parentIsInterface) { - return forEach(getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - - cachedResults[key] = inherits; - return inherits; - } - - function searchTypeReference(typeReference: ExpressionWithTypeArguments): boolean { - if (typeReference) { - const type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); + return searchTypeReference(getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + if (parentIsInterface) { + return forEach(getInterfaceBaseTypeNodes(declaration), searchTypeReference); } } return false; - } + }); + + cachedResults[key] = inherits; + return inherits; } - function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] { - let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { + function searchTypeReference(typeReference: ExpressionWithTypeArguments): boolean { + if (typeReference) { + const type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); + } + } + return false; + } + } + + function getReferencesForSuperKeyword(superKeyword: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { + return undefined; + } + // Whether 'super' occurs in a static context within a class. + let staticFlag = ModifierFlags.Static; + + switch (searchSpaceNode.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + staticFlag &= getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + default: return undefined; - } - // Whether 'super' occurs in a static context within a class. - let staticFlag = ModifierFlags.Static; + } - switch (searchSpaceNode.kind) { - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - staticFlag &= getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + const references: ReferenceEntry[] = []; + + const sourceFile = searchSpaceNode.getSourceFile(); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + forEach(possiblePositions, position => { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + + if (!node || node.kind !== SyntaxKind.SuperKeyword) { + return; + } + + const container = getSuperContainer(node, /*stopOnFunctions*/ false); + + // If we have a 'super' container, we must have an enclosing class. + // 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)); + } + }); + + const definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition, references }]; + } + + function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + + // Whether 'this' occurs in a static context within a class. + let staticFlag = ModifierFlags.Static; + + switch (searchSpaceNode.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + // fall through + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + staticFlag &= getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case SyntaxKind.SourceFile: + if (isExternalModule(searchSpaceNode)) { return undefined; - } + } + // Fall through + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + break; + // Computed properties in classes are not handled here because references to this are illegal, + // so there is no point finding references to them. + default: + return undefined; + } - const references: ReferenceEntry[] = []; + const references: ReferenceEntry[] = []; + let possiblePositions: number[]; + if (searchSpaceNode.kind === SyntaxKind.SourceFile) { + forEach(sourceFiles, sourceFile => { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { const sourceFile = searchSpaceNode.getSourceFile(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + + const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + + const displayParts = thisOrSuperSymbol && SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind( + typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: createTextSpanFromNode(thisOrSuperKeyword), + displayParts + }, + references: references + }]; + + function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void { forEach(possiblePositions, position => { cancellationToken.throwIfCancellationRequested(); const node = getTouchingWord(sourceFile, position); - - if (!node || node.kind !== SyntaxKind.SuperKeyword) { + if (!node || !isThis(node)) { return; } - const container = getSuperContainer(node, /*stopOnFunctions*/ false); + const container = getThisContainer(node, /* includeArrowFunctions */ false); - // If we have a 'super' container, we must have an enclosing class. - // 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)); - } - }); - - const definition = getDefinition(searchSpaceNode.symbol); - return [{ definition, references }]; - } - - function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[]): ReferencedSymbol[] { - let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - - // Whether 'this' occurs in a static context within a class. - let staticFlag = ModifierFlags.Static; - - switch (searchSpaceNode.kind) { - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (isObjectLiteralMethod(searchSpaceNode)) { + switch (searchSpaceNode.kind) { + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case SyntaxKind.ClassExpression: + case SyntaxKind.ClassDeclaration: + // 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)); + } + break; + case SyntaxKind.SourceFile: + if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } break; - } - // fall through - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - staticFlag &= getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case SyntaxKind.SourceFile: - if (isExternalModule(searchSpaceNode)) { - return undefined; - } - // Fall through - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.FunctionExpression: - break; - // Computed properties in classes are not handled here because references to this are illegal, - // so there is no point finding references to them. - default: - return undefined; - } - - const references: ReferenceEntry[] = []; - - let possiblePositions: number[]; - if (searchSpaceNode.kind === SyntaxKind.SourceFile) { - forEach(sourceFiles, sourceFile => { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - const sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - - const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - - const displayParts = thisOrSuperSymbol && SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind( - typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: "this", - textSpan: createTextSpanFromNode(node), - displayParts - }, - references: references - }]; - - function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void { - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); - - const node = getTouchingWord(sourceFile, position); - if (!node || !isThis(node)) { - return; - } - - const container = getThisContainer(node, /* includeArrowFunctions */ false); - - switch (searchSpaceNode.kind) { - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case SyntaxKind.ClassExpression: - case SyntaxKind.ClassDeclaration: - // 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)); - } - break; - case SyntaxKind.SourceFile: - if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - - - function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[]): ReferencedSymbol[] { - const type = getStringLiteralTypeForNode(node, typeChecker); - - if (!type) { - // nothing to do here. moving on - return undefined; - } - - const references: ReferenceEntry[] = []; - - for (const sourceFile of sourceFiles) { - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: type.text, - textSpan: createTextSpanFromNode(node), - displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - - function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { - for (const position of possiblePositions) { - cancellationToken.throwIfCancellationRequested(); - - const node = getTouchingWord(sourceFile, position); - if (!node || node.kind !== SyntaxKind.StringLiteral) { - return; - } - - const type = getStringLiteralTypeForNode(node, typeChecker); - if (type === searchType) { - references.push(getReferenceEntryFromNode(node)); - } - } - } - } - - function populateSearchSymbolSet(symbol: Symbol, location: Node): Symbol[] { - // The search set contains at least the current symbol - let result = [symbol]; - - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - const containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== SyntaxKind.ShorthandPropertyAssignment) { - const propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - - // If the symbol is an alias, add what it aliases to the list - // import {a} from "mod"; - // export {a} - // If the symbol is an alias to default declaration, add what it aliases to the list - // declare "mod" { export default class B { } } - // import B from "mod"; - //// For export specifiers, the exported name can be referring to a local symbol, e.g.: - //// import {a} from "mod"; - //// export {a as somethingElse} - //// We want the *local* declaration of 'a' as declared in the import, - //// *not* as declared within "mod" (or farther) - const aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - - // If the location is in a context sensitive location (i.e. in an object literal) try - // to get a contextual type for it, and add the property symbol from the contextual - // type to the search set - if (containingObjectLiteralElement) { - forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => { - addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - - /* Because in short-hand property assignment, location has two meaning : property name and as value of the property - * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of - * property name and variable declaration of the identifier. - * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service - * should show both 'name' in 'obj' and 'name' in variable declaration - * const name = "Foo"; - * const obj = { name }; - * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment - * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration - * will be included correctly. - */ - const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - - // If the symbol.valueDeclaration is a property parameter declaration, - // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. - // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter && - isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); } }); - - return result; } + } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], - previousIterationSymbolsCache: SymbolTable): void { - if (!symbol) { - return; - } + function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + const type = getStringLiteralTypeForNode(node, typeChecker); - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (symbol.name in previousIterationSymbolsCache) { - return; - } - - if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - forEach(symbol.getDeclarations(), declaration => { - if (isClassLike(declaration)) { - getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(declaration)); - forEach(getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { - forEach(getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - - function getPropertySymbolFromTypeReference(typeReference: ExpressionWithTypeArguments) { - if (typeReference) { - const type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - const propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push(...typeChecker.getRootSymbols(propertySymbol)); - } - - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - - function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map): Symbol { - if (contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - - // If the reference location is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this symbol to - // compare to our searchSymbol - const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => { - return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined); - }); - - if (contextualSymbol) { - return contextualSymbol; - } - - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - const propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return forEach(typeChecker.getRootSymbols(referenceSymbol), rootSymbol => { - // if it is in the list, then we are done - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!forEach(parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, cache))) { - return undefined; - } - } - - const result: Symbol[] = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); - return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); - } - - return undefined; - }); - } - - function getNameFromObjectLiteralElement(node: ObjectLiteralElement) { - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - const nameExpression = (node.name).expression; - // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (isStringOrNumericLiteral(nameExpression)) { - return (nameExpression).text; - } - return undefined; - } - return (node.name).text; - } - - function getPropertySymbolsFromContextualType(node: ObjectLiteralElement): Symbol[] { - const objectLiteral = node.parent; - const contextualType = typeChecker.getContextualType(objectLiteral); - const name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - const result: Symbol[] = []; - const symbol = contextualType.getProperty(name); - if (symbol) { - result.push(symbol); - } - - if (contextualType.flags & TypeFlags.Union) { - forEach((contextualType).types, t => { - const symbol = t.getProperty(name); - if (symbol) { - result.push(symbol); - } - }); - } - return result; - } + if (!type) { + // nothing to do here. moving on return undefined; } - /** Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations - * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class - * then we need to widen the search to include type positions as well. - * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated - * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) - * do not intersect in any of the three spaces. - */ - function getIntersectingMeaningFromDeclarations(meaning: SemanticMeaning, declarations: Declaration[]): SemanticMeaning { - if (declarations) { - let lastIterationMeaning: SemanticMeaning; - do { - // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] - // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module - // intersects with the class in the value space. - // To achieve that we will keep iterating until the result stabilizes. + const references: ReferenceEntry[] = []; - // Remember the last meaning - lastIterationMeaning = meaning; + for (const sourceFile of sourceFiles) { + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } - for (const declaration of declarations) { - const declarationMeaning = getMeaningFromDeclaration(declaration); + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: type.text, + textSpan: createTextSpanFromNode(node), + displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } + function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { + for (const position of possiblePositions) { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + if (!node || node.kind !== SyntaxKind.StringLiteral) { + return; + } + + const type = getStringLiteralTypeForNode(node, typeChecker); + if (type === searchType) { + references.push(getReferenceEntryFromNode(node)); + } + } + } + } + + function populateSearchSymbolSet(symbol: Symbol, location: Node, typeChecker: TypeChecker, implementations: boolean): Symbol[] { + // The search set contains at least the current symbol + let result = [symbol]; + + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + const containingObjectLiteralElement = getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== SyntaxKind.ShorthandPropertyAssignment) { + const propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + + // If the symbol is an alias, add what it aliases to the list + // import {a} from "mod"; + // export {a} + // If the symbol is an alias to default declaration, add what it aliases to the list + // declare "mod" { export default class B { } } + // import B from "mod"; + //// For export specifiers, the exported name can be referring to a local symbol, e.g.: + //// import {a} from "mod"; + //// export {a as somethingElse} + //// We want the *local* declaration of 'a' as declared in the import, + //// *not* as declared within "mod" (or farther) + const aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker); + if (aliasSymbol) { + result = result.concat(populateSearchSymbolSet(aliasSymbol, location, typeChecker, implementations)); + } + + // If the location is in a context sensitive location (i.e. in an object literal) try + // to get a contextual type for it, and add the property symbol from the contextual + // type to the search set + if (containingObjectLiteralElement) { + forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), contextualSymbol => { + addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + + /* Because in short-hand property assignment, location has two meaning : property name and as value of the property + * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of + * property name and variable declaration of the identifier. + * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service + * should show both 'name' in 'obj' and 'name' in variable declaration + * const name = "Foo"; + * const obj = { name }; + * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment + * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration + * will be included correctly. + */ + const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + + // If the symbol.valueDeclaration is a property parameter declaration, + // we should include both parameter declaration symbol and property declaration symbol + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. + // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter && + isParameterPropertyDeclaration(symbol.valueDeclaration)) { + result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap(), typeChecker); + } + }); + + return result; + } + + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], + previousIterationSymbolsCache: SymbolTable, typeChecker: TypeChecker): void { + if (!symbol) { + return; + } + + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (symbol.name in previousIterationSymbolsCache) { + return; + } + + if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + forEach(symbol.getDeclarations(), declaration => { + if (isClassLike(declaration)) { + getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(declaration)); + forEach(getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + forEach(getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + + function getPropertySymbolFromTypeReference(typeReference: ExpressionWithTypeArguments) { + if (typeReference) { + const type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + const propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push(...typeChecker.getRootSymbols(propertySymbol)); + } + + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache[symbol.name] = symbol; + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + + function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map, typeChecker: TypeChecker): Symbol { + if (contains(searchSymbols, referenceSymbol)) { + // If we are searching for constructor uses, they must be 'new' expressions. + return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol; + } + + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. + const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + + // If the reference location is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this symbol to + // compare to our searchSymbol + const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), contextualSymbol => { + return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined); + }); + + if (contextualSymbol) { + return contextualSymbol; + } + + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + const propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { + return propertySymbol; + } + } + + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { + return bindingElementPropertySymbol; + } + + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return forEach(typeChecker.getRootSymbols(referenceSymbol), rootSymbol => { + // if it is in the list, then we are done + if (searchSymbols.indexOf(rootSymbol) >= 0) { + return rootSymbol; + } + + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + // Parents will only be defined if implementations is true + if (parents) { + if (!forEach(parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker))) { + return undefined; } } - while (meaning !== lastIterationMeaning); + + const result: Symbol[] = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap(), typeChecker); + return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); } - return meaning; + + return undefined; + }); + } + + function getNameFromObjectLiteralElement(node: ObjectLiteralElement) { + if (node.name.kind === SyntaxKind.ComputedPropertyName) { + const nameExpression = (node.name).expression; + // treat computed property names where expression is string/numeric literal as just string/numeric literal + if (isStringOrNumericLiteral(nameExpression)) { + return (nameExpression).text; + } + return undefined; } + return (node.name).text; + } + + function getPropertySymbolsFromContextualType(node: ObjectLiteralElement, typeChecker: TypeChecker): Symbol[] { + const objectLiteral = node.parent; + const contextualType = typeChecker.getContextualType(objectLiteral); + const name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + const result: Symbol[] = []; + const symbol = contextualType.getProperty(name); + if (symbol) { + result.push(symbol); + } + + if (contextualType.flags & TypeFlags.Union) { + forEach((contextualType).types, t => { + const symbol = t.getProperty(name); + if (symbol) { + result.push(symbol); + } + }); + } + return result; + } + return undefined; + } + + /** + * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations + * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class + * then we need to widen the search to include type positions as well. + * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated + * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) + * do not intersect in any of the three spaces. + */ + function getIntersectingMeaningFromDeclarations(meaning: SemanticMeaning, declarations: Declaration[]): SemanticMeaning { + if (declarations) { + let lastIterationMeaning: SemanticMeaning; + do { + // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] + // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module + // intersects with the class in the value space. + // To achieve that we will keep iterating until the result stabilizes. + + // Remember the last meaning + lastIterationMeaning = meaning; + + for (const declaration of declarations) { + const declarationMeaning = getMeaningFromDeclaration(declaration); + + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } + while (meaning !== lastIterationMeaning); + } + return meaning; } export function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[] { diff --git a/tests/cases/fourslash/findAllRefsForRest.ts b/tests/cases/fourslash/findAllRefsForRest.ts index c3a970e9e73..65d6a3c60e3 100644 --- a/tests/cases/fourslash/findAllRefsForRest.ts +++ b/tests/cases/fourslash/findAllRefsForRest.ts @@ -7,6 +7,5 @@ ////let t: Gen; ////var { x, ...rest } = t; ////rest.[|parent|]; -const ranges = test.ranges(); -verify.referencesOf(ranges[0], ranges); -verify.referencesOf(ranges[1], ranges); + +verify.rangesReferenceEachOther(); From f1b481a1b61cd0808317b78c9a19acaea1eefa77 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 13 Jan 2017 14:08:44 -0800 Subject: [PATCH 112/175] Support completions for string literal in rest parameter --- src/compiler/checker.ts | 1 + src/compiler/types.ts | 5 +++++ src/services/completions.ts | 5 +---- tests/cases/fourslash/completionForStringLiteral7.ts | 10 ++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteral7.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a916e9cbba6..dbb1b53efc1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -84,6 +84,7 @@ namespace ts { getIndexTypeOfType, getBaseTypes, getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, getSymbolsInScope, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0906488ea33..23c55aacf26 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2341,6 +2341,11 @@ namespace ts { getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; + /** + * Gets the type of a parameter at a given position in a signature. + * Returns `any` if the index is not valid. + */ + /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; diff --git a/src/services/completions.ts b/src/services/completions.ts index bb5922af9ad..8c0d52b2c34 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -204,10 +204,7 @@ namespace ts.Completions { typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); for (const candidate of candidates) { - if (candidate.parameters.length > argumentInfo.argumentIndex) { - const parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); - } + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries); } if (entries.length) { diff --git a/tests/cases/fourslash/completionForStringLiteral7.ts b/tests/cases/fourslash/completionForStringLiteral7.ts new file mode 100644 index 00000000000..b2d250ac3fd --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral7.ts @@ -0,0 +1,10 @@ +/// + +////type T = "foo" | "bar"; +////type U = "oof" | "rab"; +////function f(x: T, ...args: U[]) { }; +////f("/*1*/", "/*2*/", "/*3*/"); + +verify.completionsAt("1", ["foo", "bar"]); +verify.completionsAt("2", ["oof", "rab"]); +verify.completionsAt("3", ["oof", "rab"]); From bc7f86c1df771ed2cce7f784eca9cde6ea26cb45 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 13 Jan 2017 15:05:08 -0800 Subject: [PATCH 113/175] Improved undefined/null handling for arithmetic operators --- src/compiler/checker.ts | 47 ++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9e4e81e3da9..cb48b2176f9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12332,16 +12332,18 @@ namespace ts { } function checkNonNullExpression(node: Expression | QualifiedName) { - const type = checkExpression(node); - if (strictNullChecks) { - const kind = getFalsyFlags(type) & TypeFlags.Nullable; - if (kind) { - error(node, kind & TypeFlags.Undefined ? kind & TypeFlags.Null ? - Diagnostics.Object_is_possibly_null_or_undefined : - Diagnostics.Object_is_possibly_undefined : - Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + + function checkNonNullType(type: Type, errorNode: Node): Type { + const kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & TypeFlags.Nullable; + if (kind) { + error(errorNode, kind & TypeFlags.Undefined ? kind & TypeFlags.Null ? + Diagnostics.Object_is_possibly_null_or_undefined : + Diagnostics.Object_is_possibly_undefined : + Diagnostics.Object_is_possibly_null); + const t = getNonNullableType(type); + return t.flags & (TypeFlags.Nullable | TypeFlags.Never) ? unknownType : t; } return type; } @@ -14880,17 +14882,9 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // TypeScript 1.0 spec (April 2014): 4.19.1 - // These operators require their operands to be of type Any, the Number primitive type, - // or an enum type. Operands of an enum type are treated - // as having the primitive type Number. If one operand is the null or undefined value, - // it is treated as having the type of the other operand. - // The result is always of the Number primitive type. - if (leftType.flags & TypeFlags.Nullable) leftType = rightType; - if (rightType.flags & TypeFlags.Nullable) rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); let suggestedOperator: SyntaxKind; // if a user tries to apply a bitwise operator to 2 boolean operands @@ -14915,16 +14909,11 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // TypeScript 1.0 spec (April 2014): 4.19.2 - // The binary + operator requires both operands to be of the Number primitive type or an enum type, - // or at least one of the operands to be of type Any or the String primitive type. - // If one operand is the null or undefined value, it is treated as having the type of the other operand. - if (leftType.flags & TypeFlags.Nullable) leftType = rightType; - if (rightType.flags & TypeFlags.Nullable) rightType = leftType; - - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, TypeFlags.Any | TypeFlags.StringLike) && !isTypeOfKind(rightType, TypeFlags.Any | TypeFlags.StringLike)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } let resultType: Type; if (isTypeOfKind(leftType, TypeFlags.NumberLike) && isTypeOfKind(rightType, TypeFlags.NumberLike)) { From a1e16d2cb492bbe49ead4baddc98b720ca63b35f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 13 Jan 2017 15:06:24 -0800 Subject: [PATCH 114/175] Accept new baselines --- ...WithNullValueAndInvalidOperator.errors.txt | 66 +-- ...orWithNullValueAndValidOperator.errors.txt | 63 ++ ...thOnlyNullValueOrUndefinedValue.errors.txt | 38 +- ...ditionOperatorWithTypeParameter.errors.txt | 12 +- ...ndefinedValueAndInvalidOperands.errors.txt | 66 +-- ...hUndefinedValueAndValidOperator.errors.txt | 63 ++ .../ambientWithStatements.errors.txt | 4 +- ...WithNullValueAndInvalidOperands.errors.txt | 542 ++++++++++-------- ...orWithNullValueAndValidOperands.errors.txt | 353 ++++++++++++ ...thOnlyNullValueOrUndefinedValue.errors.txt | 320 +++++------ ...ndefinedValueAndInvalidOperands.errors.txt | 542 ++++++++++-------- ...hUndefinedValueAndValidOperands.errors.txt | 353 ++++++++++++ .../reference/binaryArithmatic1.errors.txt | 7 + .../reference/binaryArithmatic2.errors.txt | 7 + .../reference/binaryArithmatic3.errors.txt | 8 +- .../reference/binaryArithmatic4.errors.txt | 8 +- ...wiseNotOperatorWithAnyOtherType.errors.txt | 29 +- ...itionAssignmentLHSCanBeAssigned.errors.txt | 65 +++ ...onAssignmentWithInvalidOperands.errors.txt | 36 +- ...meticAssignmentLHSCanBeAssigned.errors.txt | 47 ++ ...icAssignmentWithInvalidOperands.errors.txt | 32 +- .../compoundAssignmentLHSIsValue.errors.txt | 8 +- ...tionAssignmentLHSCanBeAssigned1.errors.txt | 47 ++ ...onAssignmentLHSCannotBeAssigned.errors.txt | 32 +- ...onentiationAssignmentLHSIsValue.errors.txt | 8 +- .../contextuallyTypedIifeStrict.errors.txt | 45 ++ ...thAnyOtherTypeInvalidOperations.errors.txt | 56 +- .../deleteOperatorWithAnyOtherType.errors.txt | 29 +- .../emitExponentiationOperator4.errors.txt | 70 +++ ...onentiationOperatorSyntaxError2.errors.txt | 32 +- ...WithNullValueAndInvalidOperands.errors.txt | 48 +- ...orWithNullValueAndValidOperands.errors.txt | 47 ++ ...thOnlyNullValueOrUndefinedValue.errors.txt | 32 +- ...ndefinedValueAndInvalidOperands.errors.txt | 48 +- ...hUndefinedValueAndValidOperands.errors.txt | 47 ++ ...gReturnStatementsAndExpressions.errors.txt | 5 +- ...thAnyOtherTypeInvalidOperations.errors.txt | 56 +- tests/baselines/reference/literals.errors.txt | 16 +- ...icalNotOperatorWithAnyOtherType.errors.txt | 29 +- .../moduleVariableArrayIndexer.errors.txt | 11 + ...negateOperatorInvalidOperations.errors.txt | 24 +- .../nonPrimitiveStrictNull.errors.txt | 14 +- tests/baselines/reference/null.errors.txt | 28 + .../reference/nullKeyword.errors.txt | 6 +- .../operatorAddNullUndefined.errors.txt | 64 ++- .../plusOperatorWithAnyOtherType.errors.txt | 29 +- .../reference/propertyAccess4.errors.txt | 6 +- .../reference/propertyAccess5.errors.txt | 6 +- .../typeofOperatorWithAnyOtherType.errors.txt | 29 +- .../voidOperatorWithAnyOtherType.errors.txt | 29 +- .../reference/widenedTypes.errors.txt | 4 +- 51 files changed, 2531 insertions(+), 1035 deletions(-) create mode 100644 tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt create mode 100644 tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt create mode 100644 tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt create mode 100644 tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt create mode 100644 tests/baselines/reference/binaryArithmatic1.errors.txt create mode 100644 tests/baselines/reference/binaryArithmatic2.errors.txt create mode 100644 tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt create mode 100644 tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt create mode 100644 tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt create mode 100644 tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt create mode 100644 tests/baselines/reference/emitExponentiationOperator4.errors.txt create mode 100644 tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt create mode 100644 tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt create mode 100644 tests/baselines/reference/moduleVariableArrayIndexer.errors.txt create mode 100644 tests/baselines/reference/null.errors.txt diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt index d18a9a13d8c..5f0d78c59d5 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt +++ b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2531: Object is possibly 'null'. ==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts (11 errors) ==== @@ -23,37 +23,37 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // null + boolean/Object var r1 = null + a; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r2 = null + b; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r3 = null + c; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r4 = a + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r5 = b + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r6 = null + c; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. // other cases var r7 = null + d; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8 = null + true; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9 = null + { a: '' }; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10 = null + foo(); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r11 = null + (() => { }); - ~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt new file mode 100644 index 00000000000..db01a42c8bd --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(15,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(17,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(18,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(19,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(20,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(21,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(22,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(23,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(24,20): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts (10 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the other operand. + + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + var d: string; + + // null + any + var r1: any = null + a; + var r2: any = a + null; + + // null + number/enum + var r3 = null + b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4 = null + 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r5 = null + c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r6 = null + E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r7 = null + E['a']; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r8 = b + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r9 = 1 + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r10 = c + null + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r11 = E.a + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r12 = E['a'] + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // null + string + var r13 = null + d; + var r14 = null + ''; + var r15 = d + null; + var r16 = '' + null; \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index 9e7e4c01ad2..aef66891be0 100644 --- a/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,20 +1,32 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,22): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (4 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (8 errors) ==== // bug 819721 var r1 = null + null; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r2 = null + undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined + null; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r4 = undefined + undefined; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt b/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt index ff7120c145d..478c4fdee3f 100644 --- a/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt +++ b/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt @@ -8,8 +8,8 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(27,15): error TS2365: Operator '+' cannot be applied to types 'Object' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(28,15): error TS2365: Operator '+' cannot be applied to types 'E' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(29,15): error TS2365: Operator '+' cannot be applied to types 'void' and 'T'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(34,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(35,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'U'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(36,15): error TS2365: Operator '+' cannot be applied to types 'T' and '() => void'. @@ -69,11 +69,11 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // other cases var r15 = t + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r16 = t + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r17 = t + t; ~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt index d61f101a544..06e8c67b105 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts (11 errors) ==== @@ -23,37 +23,37 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // undefined + boolean/Object var r1 = undefined + a; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r2 = undefined + b; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined + c; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r4 = a + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r5 = b + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r6 = undefined + c; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // other cases var r7 = undefined + d; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8 = undefined + true; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9 = undefined + { a: '' }; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10 = undefined + foo(); - ~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r11 = undefined + (() => { }); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt new file mode 100644 index 00000000000..04c0e2f3266 --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(15,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(16,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(17,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(18,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(19,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(20,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(21,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(22,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(23,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(24,20): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts (10 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the other operand. + + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + var d: string; + + // undefined + any + var r1: any = undefined + a; + var r2: any = a + undefined; + + // undefined + number/enum + var r3 = undefined + b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r4 = undefined + 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r5 = undefined + c; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r6 = undefined + E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r7 = undefined + E['a']; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r8 = b + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r9 = 1 + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r10 = c + undefined + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r11 = E.a + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r12 = E['a'] + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // undefined + string + var r13 = undefined + d; + var r14 = undefined + ''; + var r15 = d + undefined; + var r16 = '' + undefined; \ No newline at end of file diff --git a/tests/baselines/reference/ambientWithStatements.errors.txt b/tests/baselines/reference/ambientWithStatements.errors.txt index 6fb6aafd864..3e134970a1f 100644 --- a/tests/baselines/reference/ambientWithStatements.errors.txt +++ b/tests/baselines/reference/ambientWithStatements.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1036: Statements are not allowed in ambient contexts. tests/cases/compiler/ambientWithStatements.ts(3,5): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2531: Object is possibly 'null'. tests/cases/compiler/ambientWithStatements.ts(11,5): error TS1108: A 'return' statement can only be used within a function body. tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. @@ -18,7 +18,7 @@ tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' st var x; for (x in null) { } ~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2531: Object is possibly 'null'. if (true) { } else { } 1; L: var y; diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt index c043cda8e68..16a0264a805 100644 --- a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt @@ -1,234 +1,246 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,21): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,13): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,13): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,18): error TS2531: Object is possibly 'null'. -==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts (228 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts (240 errors) ==== // If one operand is the null or undefined value, it is treated as having the type of the // other operand. @@ -239,17 +251,17 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti // operator * var r1a1 = null * a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = null * b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = null * c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -257,31 +269,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1b2 = b * null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1b3 = c * null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1c1 = null * true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = null * ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = null * {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -289,32 +301,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1d2 = '' * null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1d3 = {} * null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator / var r2a1 = null / a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a2 = null / b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a3 = null / c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -322,31 +334,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2b2 = b / null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2b3 = c / null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2c1 = null / true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c2 = null / ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c3 = null / {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -354,32 +366,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2d2 = '' / null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2d3 = {} / null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator % var r3a1 = null % a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a2 = null % b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a3 = null % c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -387,31 +399,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3b2 = b % null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3b3 = c % null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3c1 = null % true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c2 = null % ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c3 = null % {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -419,32 +431,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3d2 = '' % null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r3d3 = {} % null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator - var r4a1 = null - a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a2 = null - b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a3 = null - c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -452,31 +464,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4b2 = b - null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4b3 = c - null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4c1 = null - true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c2 = null - ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c3 = null - {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -484,32 +496,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4d2 = '' - null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4d3 = {} - null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator << var r5a1 = null << a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a2 = null << b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a3 = null << c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -517,31 +529,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5b2 = b << null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5b3 = c << null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5c1 = null << true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c2 = null << ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c3 = null << {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -549,32 +561,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5d2 = '' << null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r5d3 = {} << null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator >> var r6a1 = null >> a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a2 = null >> b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a3 = null >> c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -582,31 +594,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6b2 = b >> null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6b3 = c >> null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6c1 = null >> true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c2 = null >> ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c3 = null >> {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -614,32 +626,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6d2 = '' >> null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r6d3 = {} >> null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator >>> var r7a1 = null >>> a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a2 = null >>> b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a3 = null >>> c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -647,31 +659,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7b2 = b >>> null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7b3 = c >>> null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7c1 = null >>> true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c2 = null >>> ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c3 = null >>> {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -679,185 +691,209 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7d2 = '' >>> null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r7d3 = {} >>> null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator & var r8a1 = null & a; - ~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a2 = null & b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a3 = null & c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8b1 = a & null; - ~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8b2 = b & null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r8b3 = c & null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r8c1 = null & true; - ~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c2 = null & ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c3 = null & {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8d1 = true & null; - ~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8d2 = '' & null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r8d3 = {} & null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator ^ var r9a1 = null ^ a; - ~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a2 = null ^ b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a3 = null ^ c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9b1 = a ^ null; - ~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9b2 = b ^ null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r9b3 = c ^ null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r9c1 = null ^ true; - ~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c2 = null ^ ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c3 = null ^ {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9d1 = true ^ null; - ~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9d2 = '' ^ null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r9d3 = {} ^ null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. // operator | var r10a1 = null | a; - ~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a2 = null | b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a3 = null | c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10b1 = a | null; - ~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10b2 = b | null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r10b3 = c | null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r10c1 = null | true; - ~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c2 = null | ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c3 = null | {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10d1 = true | null; - ~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10d2 = '' | null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r10d3 = {} | null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..426db291224 --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt @@ -0,0 +1,353 @@ +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(13,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(16,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(17,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(18,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(19,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(20,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(23,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(24,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(25,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(26,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(27,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(28,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(29,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(30,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(34,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(35,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(36,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(37,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(38,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(39,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(40,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(43,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(44,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(45,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(46,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(47,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(48,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(49,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(50,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(53,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(54,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(55,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(56,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(57,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(58,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(59,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(60,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(63,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(64,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(65,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(66,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(67,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(68,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(69,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(70,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(73,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(74,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(75,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(76,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(77,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(78,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(79,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(80,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(83,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(84,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(85,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(86,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(87,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(88,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(89,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(90,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(93,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(94,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(95,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(96,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(97,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(98,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(99,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(100,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(103,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(104,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(105,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(106,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(107,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(108,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(109,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(110,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts (80 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var ra1 = null * a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra2 = null * b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra3 = null * 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra4 = null * E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra5 = a * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra6 = b * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra7 = 0 * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra8 = E.b * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator / + var rb1 = null / a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb2 = null / b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb3 = null / 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb4 = null / E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb5 = a / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb6 = b / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb7 = 0 / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb8 = E.b / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator % + var rc1 = null % a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc2 = null % b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc3 = null % 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc4 = null % E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc5 = a % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc6 = b % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc7 = 0 % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc8 = E.b % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator - + var rd1 = null - a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd2 = null - b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd3 = null - 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd4 = null - E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd5 = a - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd6 = b - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd7 = 0 - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd8 = E.b - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator << + var re1 = null << a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re2 = null << b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re3 = null << 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re4 = null << E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re5 = a << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re6 = b << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re7 = 0 << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re8 = E.b << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >> + var rf1 = null >> a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf2 = null >> b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf3 = null >> 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf4 = null >> E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf5 = a >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf6 = b >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf7 = 0 >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf8 = E.b >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >>> + var rg1 = null >>> a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg2 = null >>> b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg3 = null >>> 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg4 = null >>> E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg5 = a >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg6 = b >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg7 = 0 >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg8 = E.b >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator & + var rh1 = null & a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh2 = null & b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh3 = null & 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh4 = null & E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh5 = a & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh6 = b & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh7 = 0 & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh8 = E.b & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator ^ + var ri1 = null ^ a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri2 = null ^ b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri3 = null ^ 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri4 = null ^ E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri5 = a ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri6 = b ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri7 = 0 ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri8 = E.b ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator | + var rj1 = null | a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj2 = null | b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj3 = null | 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj4 = null | E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj5 = a | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj6 = b | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj7 = 0 | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj8 = E.b | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index d00eee1d4dd..e67db44a780 100644 --- a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,302 +1,302 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,20): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,20): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,23): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts (80 errors) ==== // operator * var ra1 = null * null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ra2 = null * undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var ra3 = undefined * null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ra4 = undefined * undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator / var rb1 = null / null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rb2 = null / undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rb3 = undefined / null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rb4 = undefined / undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator % var rc1 = null % null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rc2 = null % undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rc3 = undefined % null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rc4 = undefined % undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator - var rd1 = null - null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rd2 = null - undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rd3 = undefined - null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rd4 = undefined - undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator << var re1 = null << null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var re2 = null << undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var re3 = undefined << null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var re4 = undefined << undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >> var rf1 = null >> null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rf2 = null >> undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rf3 = undefined >> null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rf4 = undefined >> undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >>> var rg1 = null >>> null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rg2 = null >>> undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rg3 = undefined >>> null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rg4 = undefined >>> undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator & var rh1 = null & null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rh2 = null & undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rh3 = undefined & null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rh4 = undefined & undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator ^ var ri1 = null ^ null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ri2 = null ^ undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var ri3 = undefined ^ null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ri4 = undefined ^ undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator | var rj1 = null | null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rj2 = null | undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rj3 = undefined | null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rj4 = undefined | undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt index 9ee53c2f15c..8a9d014f2c2 100644 --- a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,234 +1,246 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,21): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,18): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts (228 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts (240 errors) ==== // If one operand is the undefined or undefined value, it is treated as having the type of the // other operand. @@ -239,17 +251,17 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti // operator * var r1a1 = undefined * a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = undefined * b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = undefined * c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -257,31 +269,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1b2 = b * undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1b3 = c * undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1c1 = undefined * true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = undefined * ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = undefined * {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -289,32 +301,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1d2 = '' * undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1d3 = {} * undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator / var r2a1 = undefined / a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a2 = undefined / b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a3 = undefined / c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -322,31 +334,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2b2 = b / undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2b3 = c / undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2c1 = undefined / true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c2 = undefined / ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c3 = undefined / {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -354,32 +366,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2d2 = '' / undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r2d3 = {} / undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator % var r3a1 = undefined % a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a2 = undefined % b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a3 = undefined % c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -387,31 +399,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3b2 = b % undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3b3 = c % undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3c1 = undefined % true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c2 = undefined % ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c3 = undefined % {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -419,32 +431,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3d2 = '' % undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3d3 = {} % undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator - var r4a1 = undefined - a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a2 = undefined - b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a3 = undefined - c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -452,31 +464,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4b2 = b - undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4b3 = c - undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4c1 = undefined - true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c2 = undefined - ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c3 = undefined - {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -484,32 +496,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4d2 = '' - undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r4d3 = {} - undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator << var r5a1 = undefined << a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a2 = undefined << b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a3 = undefined << c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -517,31 +529,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5b2 = b << undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5b3 = c << undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5c1 = undefined << true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c2 = undefined << ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c3 = undefined << {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -549,32 +561,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5d2 = '' << undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r5d3 = {} << undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >> var r6a1 = undefined >> a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a2 = undefined >> b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a3 = undefined >> c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -582,31 +594,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6b2 = b >> undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6b3 = c >> undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6c1 = undefined >> true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c2 = undefined >> ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c3 = undefined >> {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -614,32 +626,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6d2 = '' >> undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r6d3 = {} >> undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >>> var r7a1 = undefined >>> a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a2 = undefined >>> b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a3 = undefined >>> c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -647,31 +659,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7b2 = b >>> undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7b3 = c >>> undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7c1 = undefined >>> true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c2 = undefined >>> ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c3 = undefined >>> {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -679,185 +691,209 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7d2 = '' >>> undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r7d3 = {} >>> undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator & var r8a1 = undefined & a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a2 = undefined & b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a3 = undefined & c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8b1 = a & undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8b2 = b & undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r8b3 = c & undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r8c1 = undefined & true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c2 = undefined & ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c3 = undefined & {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8d1 = true & undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8d2 = '' & undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r8d3 = {} & undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator ^ var r9a1 = undefined ^ a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a2 = undefined ^ b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a3 = undefined ^ c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9b1 = a ^ undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9b2 = b ^ undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r9b3 = c ^ undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r9c1 = undefined ^ true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c2 = undefined ^ ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c3 = undefined ^ {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9d1 = true ^ undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9d2 = '' ^ undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r9d3 = {} ^ undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator | var r10a1 = undefined | a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a2 = undefined | b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a3 = undefined | c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10b1 = a | undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10b2 = b | undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r10b3 = c | undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r10c1 = undefined | true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c2 = undefined | ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c3 = undefined | {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10d1 = true | undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10d2 = '' | undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r10d3 = {} | undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..246b642603c --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt @@ -0,0 +1,353 @@ +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(13,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(14,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(17,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(18,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(19,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(20,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(23,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(24,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(25,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(26,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(27,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(28,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(29,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(30,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(33,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(35,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(36,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(37,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(38,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(39,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(40,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(43,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(44,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(45,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(46,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(47,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(48,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(49,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(50,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(53,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(54,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(55,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(56,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(57,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(58,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(59,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(60,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(63,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(64,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(65,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(66,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(67,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(68,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(69,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(70,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(73,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(74,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(75,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(76,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(77,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(78,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(79,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(80,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(83,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(84,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(85,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(86,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(87,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(88,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(89,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(90,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(93,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(94,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(95,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(96,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(97,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(98,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(99,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(100,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(103,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(104,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(105,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(106,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(107,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(108,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(109,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(110,17): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts (80 errors) ==== + // If one operand is the undefined or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var ra1 = undefined * a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra2 = undefined * b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra3 = undefined * 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra4 = undefined * E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra5 = a * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra6 = b * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra7 = 0 * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra8 = E.b * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator / + var rb1 = undefined / a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb2 = undefined / b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb3 = undefined / 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb4 = undefined / E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb5 = a / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb6 = b / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb7 = 0 / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb8 = E.b / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator % + var rc1 = undefined % a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc2 = undefined % b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc3 = undefined % 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc4 = undefined % E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc5 = a % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc6 = b % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc7 = 0 % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc8 = E.b % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator - + var rd1 = undefined - a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd2 = undefined - b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd3 = undefined - 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd4 = undefined - E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd5 = a - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd6 = b - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd7 = 0 - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd8 = E.b - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator << + var re1 = undefined << a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re2 = undefined << b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re3 = undefined << 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re4 = undefined << E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re5 = a << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re6 = b << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re7 = 0 << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re8 = E.b << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >> + var rf1 = undefined >> a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf2 = undefined >> b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf3 = undefined >> 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf4 = undefined >> E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf5 = a >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf6 = b >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf7 = 0 >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf8 = E.b >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >>> + var rg1 = undefined >>> a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg2 = undefined >>> b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg3 = undefined >>> 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg4 = undefined >>> E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg5 = a >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg6 = b >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg7 = 0 >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg8 = E.b >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator & + var rh1 = undefined & a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh2 = undefined & b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh3 = undefined & 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh4 = undefined & E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh5 = a & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh6 = b & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh7 = 0 & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh8 = E.b & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator ^ + var ri1 = undefined ^ a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri2 = undefined ^ b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri3 = undefined ^ 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri4 = undefined ^ E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri5 = a ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri6 = b ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri7 = 0 ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri8 = E.b ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator | + var rj1 = undefined | a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj2 = undefined | b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj3 = undefined | 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj4 = undefined | E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj5 = a | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj6 = b | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj7 = 0 | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj8 = E.b | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic1.errors.txt b/tests/baselines/reference/binaryArithmatic1.errors.txt new file mode 100644 index 00000000000..51c0b649890 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic1.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/binaryArithmatic1.ts(1,13): error TS2531: Object is possibly 'null'. + + +==== tests/cases/compiler/binaryArithmatic1.ts (1 errors) ==== + var v = 4 | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic2.errors.txt b/tests/baselines/reference/binaryArithmatic2.errors.txt new file mode 100644 index 00000000000..28f379c30e2 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/binaryArithmatic2.ts(1,13): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/binaryArithmatic2.ts (1 errors) ==== + var v = 4 | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic3.errors.txt b/tests/baselines/reference/binaryArithmatic3.errors.txt index 6dffe5e150c..1457407a7b8 100644 --- a/tests/baselines/reference/binaryArithmatic3.errors.txt +++ b/tests/baselines/reference/binaryArithmatic3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/binaryArithmatic3.ts(1,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/compiler/binaryArithmatic3.ts(1,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/binaryArithmatic3.ts(1,9): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/binaryArithmatic3.ts(1,21): error TS2532: Object is possibly 'undefined'. ==== tests/cases/compiler/binaryArithmatic3.ts (2 errors) ==== var v = undefined | undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic4.errors.txt b/tests/baselines/reference/binaryArithmatic4.errors.txt index f72c23073ca..fe7523e0884 100644 --- a/tests/baselines/reference/binaryArithmatic4.errors.txt +++ b/tests/baselines/reference/binaryArithmatic4.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/binaryArithmatic4.ts(1,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/compiler/binaryArithmatic4.ts(1,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/binaryArithmatic4.ts(1,9): error TS2531: Object is possibly 'null'. +tests/cases/compiler/binaryArithmatic4.ts(1,16): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/binaryArithmatic4.ts (2 errors) ==== var v = null | null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt index 66d4cbb628e..262ac042c68 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,33): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,33): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,26): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,38): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (6 errors) ==== // ~ operator on any type @@ -51,14 +54,20 @@ tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNot var ResultIsNumber14 = ~A.foo(); var ResultIsNumber15 = ~(ANY + ANY1); var ResultIsNumber16 = ~(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber17 = ~(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber18 = ~(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple ~ operators var ResultIsNumber19 = ~~ANY; diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt new file mode 100644 index 00000000000..08d8fd0c6d3 --- /dev/null +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt @@ -0,0 +1,65 @@ +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(32,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(33,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(39,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(40,7): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts (4 errors) ==== + enum E { a, b } + + var a: any; + var b: void; + + var x1: any; + x1 += a; + x1 += b; + x1 += true; + x1 += 0; + x1 += ''; + x1 += E.a; + x1 += {}; + x1 += null; + x1 += undefined; + + var x2: string; + x2 += a; + x2 += b; + x2 += true; + x2 += 0; + x2 += ''; + x2 += E.a; + x2 += {}; + x2 += null; + x2 += undefined; + + var x3: number; + x3 += a; + x3 += 0; + x3 += E.a; + x3 += null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 += undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x4: E; + x4 += a; + x4 += 0; + x4 += E.a; + x4 += null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x4 += undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x5: boolean; + x5 += a; + + var x6: {}; + x6 += a; + x6 += ''; + + var x7: void; + x7 += a; \ No newline at end of file diff --git a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt index cadc5c945d1..1812065f149 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt @@ -3,22 +3,22 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(8,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(15,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(16,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(17,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(18,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(19,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(24,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(25,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(26,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(27,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(28,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(33,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(34,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(35,1): error TS2365: Operator '+=' cannot be applied to types 'number' and '{}'. @@ -49,11 +49,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. x1 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x1 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x2: {}; x2 += a; @@ -72,11 +72,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. x2 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x2 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x3: void; x3 += a; @@ -95,11 +95,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'. x3 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x3 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x4: number; x4 += a; diff --git a/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt b/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt new file mode 100644 index 00000000000..f438045a45f --- /dev/null +++ b/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(11,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(12,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(18,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(19,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(25,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(26,7): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts (6 errors) ==== + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + + var x1: any; + x1 *= a; + x1 *= b; + x1 *= c; + x1 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x1 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x2: number; + x2 *= a; + x2 *= b; + x2 *= c; + x2 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x2 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x3: E; + x3 *= a; + x3 *= b; + x3 *= c; + x3 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt b/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt index 9367285ef93..7429445b422 100644 --- a/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt @@ -10,9 +10,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(13,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(13,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(14,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(14,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(14,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(15,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(15,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(15,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(18,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(19,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(19,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -25,9 +25,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(24,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(24,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(25,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(25,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(25,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(26,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(26,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(26,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(29,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(30,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -40,9 +40,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(35,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(35,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(36,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(36,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(36,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(37,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(37,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(41,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(41,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -55,9 +55,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(46,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(46,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(47,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(47,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(48,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(48,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(48,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(51,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(52,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(53,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -108,12 +108,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x1 *= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x2: string; x2 *= a; @@ -149,12 +149,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x2 *= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x3: {}; x3 *= a; @@ -190,12 +190,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x3 *= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x4: void; x4 *= a; @@ -231,12 +231,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x4 *= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x5: number; x5 *= b; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt index bc6bb41b27f..8948467c590 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt @@ -17,6 +17,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(42,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(48,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -55,6 +56,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(105,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(108,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(109,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -74,7 +76,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(123,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (76 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value: any; @@ -158,6 +160,8 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa null *= value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. null += value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -295,6 +299,8 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa (null) *= value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~~~ +!!! error TS2531: Object is possibly 'null'. (null) += value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt new file mode 100644 index 00000000000..26f23028dfa --- /dev/null +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(11,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(12,8): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(18,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(19,8): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(25,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(26,8): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts (6 errors) ==== + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + + var x1: any; + x1 **= a; + x1 **= b; + x1 **= c; + x1 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x1 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x2: number; + x2 **= a; + x2 **= b; + x2 **= c; + x2 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x2 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x3: E; + x3 **= a; + x3 **= b; + x3 **= c; + x3 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt index 8d152712808..6d48d968638 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt @@ -10,9 +10,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(13,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(13,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(18,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(19,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(19,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -25,9 +25,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(24,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(24,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(29,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(30,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -40,9 +40,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(35,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(35,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(37,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(37,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(41,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(41,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -55,9 +55,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(46,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(46,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(47,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(47,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(48,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(48,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(48,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(51,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(52,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(53,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -108,12 +108,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x1 **= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x2: string; x2 **= a; @@ -149,12 +149,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x2 **= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x3: {}; x3 **= a; @@ -190,12 +190,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x3 **= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x4: void; x4 **= a; @@ -231,12 +231,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. x4 **= undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var x5: number; x5 **= b; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt index 22eeb18ac4a..51b69f81620 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt @@ -8,6 +8,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(30,1): error TS2539: Cannot assign to 'E' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(32,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(36,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(38,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -28,6 +29,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(75,2): error TS2539: Cannot assign to 'E' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(76,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(78,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(79,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(80,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -38,7 +40,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(85,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (38 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (40 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value: any; @@ -94,6 +96,8 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm null **= value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. true **= value; ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -176,6 +180,8 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm (null) **= value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~~~ +!!! error TS2531: Object is possibly 'null'. (true) **= value; ~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt b/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt new file mode 100644 index 00000000000..220204fc536 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(14,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(15,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(16,17): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts (3 errors) ==== + // arrow + (jake => { })("build"); + // function expression + (function (cats) { })("lol"); + // Lots of Irritating Superfluous Parentheses + (function (x) { } ("!")); + ((((function (y) { }))))("-"); + // multiple arguments + ((a, b, c) => { })("foo", 101, false); + // default parameters + ((m = 10) => m + 1)(12); + ((n = 10) => n + 1)(); + // optional parameters + ((j?) => j + 1)(12); + ~ +!!! error TS2532: Object is possibly 'undefined'. + ((k?) => k + 1)(); + ~ +!!! error TS2532: Object is possibly 'undefined'. + ((l, o?) => l + o)(12); // o should be any + ~ +!!! error TS2532: Object is possibly 'undefined'. + // rest parameters + ((...numbers) => numbers.every(n => n > 0))(5,6,7); + ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); + ((...noNumbers) => noNumbers.some(n => n > 0))(); + ((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); + // destructuring parameters (with defaults too!) + (({ q }) => q)({ q : 13 }); + (({ p = 14 }) => p)({ p : 15 }); + (({ r = 17 } = { r: 18 }) => r)({r : 19}); + (({ u = 22 } = { u: 23 }) => u)(); + // contextually typed parameters. + let twelve = (f => f(12))(i => i); + let eleven = (o => o.a(11))({ a: function(n) { return n; } }); + // missing arguments + (function(x, undefined) { return x; })(42); + ((x, y, z) => 42)(); + \ No newline at end of file diff --git a/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt b/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt index e42b6ff67b4..e5456d6f0bd 100644 --- a/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt +++ b/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt @@ -17,21 +17,27 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,34): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,34): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,32): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,32): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,37): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(63,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -50,7 +56,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(72,12): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (50 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (56 errors) ==== // -- operator on any type var ANY1: any; var ANY2: any[] = ["", ""]; @@ -137,18 +143,24 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp var ResultIsNumber19 = --(null + undefined); ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber20 = --(null + null); ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber21 = --(undefined + undefined); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber22 = --obj1.x; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -165,18 +177,24 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp var ResultIsNumber26 = (null + undefined)--; ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber27 = (null + null)--; ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber28 = (undefined + undefined)--; ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber29 = obj1.x--; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt index 69153fc235c..819f1c39050 100644 --- a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt @@ -9,12 +9,15 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(42,32): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(43,32): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,33): error TS2703: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2703: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,40): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2703: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,40): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,45): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,32): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,39): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,32): error TS2703: The operand of a delete operator must be a property reference @@ -25,7 +28,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(57,8): error TS2703: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (25 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (28 errors) ==== // delete operator on any type var ANY: any; @@ -93,20 +96,26 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~~~~~~~~~~ !!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean17 = delete (null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~~~~~~~~ !!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsBoolean18 = delete (null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~~~ !!! error TS2703: The operand of a delete operator must be a property reference + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsBoolean19 = delete (undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple delete operators var ResultIsBoolean20 = delete delete ANY; diff --git a/tests/baselines/reference/emitExponentiationOperator4.errors.txt b/tests/baselines/reference/emitExponentiationOperator4.errors.txt new file mode 100644 index 00000000000..e8f46874ad8 --- /dev/null +++ b/tests/baselines/reference/emitExponentiationOperator4.errors.txt @@ -0,0 +1,70 @@ +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(14,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(15,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(16,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(17,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(18,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(21,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(22,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(23,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(24,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(25,6): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts (10 errors) ==== + var temp: any; + + (temp) ** 3; + (--temp) ** 3; + (++temp) ** 3; + (temp--) ** 3; + (temp++) ** 3; + + 1 ** (--temp) ** 3; + 1 ** (++temp) ** 3; + 1 ** (temp--) ** 3; + 1 ** (temp++) ** 3; + + (void --temp) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp--) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void 3) ** 4; + ~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp++) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp--) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + + 1 ** (void --temp) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp--) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void 3) ** 4; + ~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp++) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp--) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + (~ --temp) ** 3; + (~ temp--) ** 3; + (~ 3) ** 4; + (~ temp++) ** 4; + (~ temp--) ** 4; + + 1 ** (~ --temp) ** 3; + 1 ** (~ temp--) ** 3; + 1 ** (~ 3) ** 4; + 1 ** (~ temp++) ** 4; + 1 ** (~ temp--) ** 4; \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt b/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt index 6ac93ecf27a..1075c505794 100644 --- a/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt @@ -42,15 +42,25 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(25,6): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(26,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(26,6): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(28,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(28,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(29,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(29,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(30,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(30,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(31,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(31,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(32,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(32,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(34,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(34,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(35,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(35,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(36,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(36,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(37,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(37,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(38,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(38,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(40,1): error TS17006: An unary expression with the '~' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(41,1): error TS17006: An unary expression with the '~' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. @@ -89,7 +99,7 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(68,1): error TS17007: A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. -==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (89 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (99 errors) ==== // Error: early syntax error using ES7 SimpleUnaryExpression on left-hand side without () var temp: any; @@ -207,34 +217,54 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE void --temp ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp-- ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void 3 ** 4; ~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp++ ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp-- ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void --temp ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp-- ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void 3 ** 4; ~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp++ ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp-- ** 4 ; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. ~ --temp ** 3; diff --git a/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt index 99535985628..2d0b76f28cc 100644 --- a/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,18): error TS2531: Object is possibly 'null'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts (24 errors) ==== @@ -35,17 +35,17 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul // operator ** var r1a1 = null ** a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = null ** b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = null ** c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -53,31 +53,31 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1b2 = b ** null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1b3 = c ** null; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1c1 = null ** true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = null ** ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = null ** {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -85,14 +85,14 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1d2 = '' ** null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r1d3 = {} ** null; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..c8a462c0f54 --- /dev/null +++ b/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(13,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(14,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(15,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(17,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(18,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(19,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(20,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts (8 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator ** + var r1 = null ** a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2 = null ** b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3 = null ** 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4 = null ** E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r5 = a ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r6 = b ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r7 = 0 ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r8 = E.b ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index 86f4930e77c..20b004625ca 100644 --- a/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,33 +1,33 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts (8 errors) ==== // operator ** var r1 = null ** null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2 = null ** undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined ** null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4 = undefined ** undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt index f456e0f554f..ce14298d02d 100644 --- a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,18): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts (24 errors) ==== @@ -35,17 +35,17 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd // operator ** var r1a1 = undefined ** a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = undefined ** b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = undefined ** c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -53,31 +53,31 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1b2 = b ** undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1b3 = c ** undefined; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1c1 = undefined ** true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = undefined ** ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = undefined ** {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -85,14 +85,14 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1d2 = '' ** undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r1d3 = {} ** undefined; ~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..ce9843a9612 --- /dev/null +++ b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(13,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(14,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(17,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(18,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(19,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(20,18): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts (8 errors) ==== + // If one operand is the undefined or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var rk1 = undefined ** a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk2 = undefined ** b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk3 = undefined ** 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk4 = undefined ** E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk5 = a ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk6 = b ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk7 = 0 ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk8 = E.b ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt index 1ccc296b75b..e0c552141b2 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt @@ -1,10 +1,11 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(3,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(101,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(106,16): error TS2378: A 'get' accessor must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(128,15): error TS2532: Object is possibly 'undefined'. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(129,5): error TS1003: Identifier expected. -==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (4 errors) ==== +==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (5 errors) ==== function f1(): string { @@ -139,6 +140,8 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(129,5): e // if no return statements are present but we are a get accessor. throw null; throw undefined. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } ~ !!! error TS1003: Identifier expected. diff --git a/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt b/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt index 0a303d12bf3..bf980bfd153 100644 --- a/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt +++ b/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt @@ -17,21 +17,27 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,34): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,34): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,32): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,32): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,37): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(63,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -45,7 +51,7 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(69,12): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (45 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (51 errors) ==== // ++ operator on any type var ANY1: any; var ANY2: any[] = [1, 2]; @@ -132,18 +138,24 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp var ResultIsNumber19 = ++(null + undefined); ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber20 = ++(null + null); ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber21 = ++(undefined + undefined); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber22 = ++obj1.x; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -160,18 +172,24 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp var ResultIsNumber26 = (null + undefined)++; ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber27 = (null + null)++; ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber28 = (undefined + undefined)++; ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber29 = obj1.x++; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/literals.errors.txt b/tests/baselines/reference/literals.errors.txt index 6fa1d7d3abd..ae058e0b530 100644 --- a/tests/baselines/reference/literals.errors.txt +++ b/tests/baselines/reference/literals.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/expressions/literals/literals.ts(9,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/literals/literals.ts(9,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/literals/literals.ts(10,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/literals/literals.ts(10,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/literals/literals.ts(9,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/literals/literals.ts(9,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/literals/literals.ts(10,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/literals/literals.ts(10,21): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/literals/literals.ts(20,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o1'. tests/cases/conformance/expressions/literals/literals.ts(25,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o3'. @@ -17,14 +17,14 @@ tests/cases/conformance/expressions/literals/literals.ts(25,9): error TS1085: Oc var nu = null / null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var u = undefined / undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var b: boolean; var b = true; diff --git a/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt index 02b4bf16fd2..0cb9869ca4c 100644 --- a/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt @@ -1,10 +1,13 @@ -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,34): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,34): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(57,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts (4 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts (7 errors) ==== // ! operator on any type var ANY: any; @@ -50,14 +53,20 @@ tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNot var ResultIsBoolean15 = !A.foo(); var ResultIsBoolean16 = !(ANY + ANY1); var ResultIsBoolean17 = !(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsBoolean18 = !(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsBoolean19 = !(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple ! operators var ResultIsBoolean20 = !!ANY; diff --git a/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt b/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt new file mode 100644 index 00000000000..f0c070375f6 --- /dev/null +++ b/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/moduleVariableArrayIndexer.ts(3,13): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/moduleVariableArrayIndexer.ts (1 errors) ==== + module Bar { + export var a = 1; + var t = undefined[a][a]; // CG: var t = undefined[Bar.a][a]; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt index 3bc5689d170..e0f818ba9c1 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt +++ b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt @@ -1,12 +1,12 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,15): error TS1109: Expression expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,25): error TS1005: '=' expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,26): error TS1109: Expression expected. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,29): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,29): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(12,14): error TS1109: Expression expected. @@ -25,19 +25,19 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator // invalid expressions var NUMBER2 = -(null - undefined); ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var NUMBER3 = -(null - null); ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var NUMBER4 = -(undefined - undefined); ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // miss operand var NUMBER =-; diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt index de6fbfcf698..473011aaa7f 100644 --- a/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt +++ b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt @@ -12,21 +12,17 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(22,5): erro Type 'null' is not assignable to type 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(27,5): error TS2531: Object is possibly 'null'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,5): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,7): error TS2339: Property 'toString' does not exist on type 'never'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,5): error TS2533: Object is possibly 'null' or 'undefined'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,7): error TS2339: Property 'toString' does not exist on type 'never'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,5): error TS2531: Object is possibly 'null'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,7): error TS2339: Property 'toString' does not exist on type 'never'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(41,5): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,5): error TS2532: Object is possibly 'undefined'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,7): error TS2339: Property 'toString' does not exist on type 'never'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): error TS2531: Object is possibly 'null'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(52,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(53,14): error TS2344: Type 'null' does not satisfy the constraint 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(54,14): error TS2344: Type 'undefined' does not satisfy the constraint 'object'. -==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (22 errors) ==== +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (18 errors) ==== var a: object declare var b: object | null @@ -80,16 +76,12 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(54,14): err d.toString(); // error, undefined ~ !!! error TS2532: Object is possibly 'undefined'. - ~~~~~~~~ -!!! error TS2339: Property 'toString' does not exist on type 'never'. } if (d == null) { d.toString(); // error, undefined | null ~ !!! error TS2533: Object is possibly 'null' or 'undefined'. - ~~~~~~~~ -!!! error TS2339: Property 'toString' does not exist on type 'never'. } else { d.toString(); // object } @@ -98,8 +90,6 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(54,14): err d.toString(); // error, null ~ !!! error TS2531: Object is possibly 'null'. - ~~~~~~~~ -!!! error TS2339: Property 'toString' does not exist on type 'never'. } else { d.toString(); // error, object | undefined ~ @@ -110,8 +100,6 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(54,14): err d.toString(); // error, undefined ~ !!! error TS2532: Object is possibly 'undefined'. - ~~~~~~~~ -!!! error TS2339: Property 'toString' does not exist on type 'never'. } else { d.toString(); // error, object | null ~ diff --git a/tests/baselines/reference/null.errors.txt b/tests/baselines/reference/null.errors.txt new file mode 100644 index 00000000000..f957507438c --- /dev/null +++ b/tests/baselines/reference/null.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/null.ts(4,9): error TS2531: Object is possibly 'null'. + + +==== tests/cases/compiler/null.ts (1 errors) ==== + + var x=null; + var y=3+x; + var z=3+null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + class C { + } + function f() { + return null; + return new C(); + } + function g() { + return null; + return 3; + } + interface I { + x:any; + y:number; + } + var w:I={x:null,y:3}; + + + \ No newline at end of file diff --git a/tests/baselines/reference/nullKeyword.errors.txt b/tests/baselines/reference/nullKeyword.errors.txt index a140fce0b0f..b815b61b676 100644 --- a/tests/baselines/reference/nullKeyword.errors.txt +++ b/tests/baselines/reference/nullKeyword.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/nullKeyword.ts(1,6): error TS2339: Property 'foo' does not exist on type 'null'. +tests/cases/compiler/nullKeyword.ts(1,1): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/nullKeyword.ts (1 errors) ==== null.foo; - ~~~ -!!! error TS2339: Property 'foo' does not exist on type 'null'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/operatorAddNullUndefined.errors.txt b/tests/baselines/reference/operatorAddNullUndefined.errors.txt index 269ee0a5166..871ef3fc98f 100644 --- a/tests/baselines/reference/operatorAddNullUndefined.errors.txt +++ b/tests/baselines/reference/operatorAddNullUndefined.errors.txt @@ -1,32 +1,68 @@ -tests/cases/compiler/operatorAddNullUndefined.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/compiler/operatorAddNullUndefined.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/compiler/operatorAddNullUndefined.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/compiler/operatorAddNullUndefined.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(2,17): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(3,17): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(5,22): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(6,14): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(7,14): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(8,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(9,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(16,17): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(17,17): error TS2532: Object is possibly 'undefined'. -==== tests/cases/compiler/operatorAddNullUndefined.ts (4 errors) ==== +==== tests/cases/compiler/operatorAddNullUndefined.ts (16 errors) ==== enum E { x } var x1 = null + null; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x2 = null + undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x3 = undefined + null; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x4 = undefined + undefined; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x5 = 1 + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x6 = 1 + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x7 = null + 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x8 = undefined + 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x9 = "test" + null; var x10 = "test" + undefined; var x11 = null + "test"; var x12 = undefined + "test"; var x13 = null + E.x + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x14 = undefined + E.x + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x15 = E.x + null - var x16 = E.x + undefined \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var x16 = E.x + undefined + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt index 6c0f113b17b..c316cf92e6d 100644 --- a/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt @@ -1,10 +1,13 @@ -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,33): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,33): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,38): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(54,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (4 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (7 errors) ==== // + operator on any type var ANY: any; @@ -51,14 +54,20 @@ tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWith var ResultIsNumber15 = +A.foo(); var ResultIsNumber16 = +(ANY + ANY1); var ResultIsNumber17 = +(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber18 = +(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber19 = +(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // miss assignment operators +ANY; diff --git a/tests/baselines/reference/propertyAccess4.errors.txt b/tests/baselines/reference/propertyAccess4.errors.txt index cdc772ba528..fc491d8c7a9 100644 --- a/tests/baselines/reference/propertyAccess4.errors.txt +++ b/tests/baselines/reference/propertyAccess4.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/propertyAccess4.ts(1,6): error TS2339: Property 'toBAZ' does not exist on type 'null'. +tests/cases/compiler/propertyAccess4.ts(1,1): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/propertyAccess4.ts (1 errors) ==== null.toBAZ(); - ~~~~~ -!!! error TS2339: Property 'toBAZ' does not exist on type 'null'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccess5.errors.txt b/tests/baselines/reference/propertyAccess5.errors.txt index 81c05c5342b..4f7e7f4bcd6 100644 --- a/tests/baselines/reference/propertyAccess5.errors.txt +++ b/tests/baselines/reference/propertyAccess5.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/propertyAccess5.ts(1,11): error TS2339: Property 'toBAZ' does not exist on type 'undefined'. +tests/cases/compiler/propertyAccess5.ts(1,1): error TS2532: Object is possibly 'undefined'. ==== tests/cases/compiler/propertyAccess5.ts (1 errors) ==== undefined.toBAZ(); - ~~~~~ -!!! error TS2339: Property 'toBAZ' does not exist on type 'undefined'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt index 94bca545609..3680b1be60f 100644 --- a/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/typeofOperatorWithAnyOtherType.errors.txt @@ -1,6 +1,9 @@ -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,32): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,32): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,32): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,32): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,39): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,32): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,39): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,32): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,44): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(58,1): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(68,1): error TS7028: Unused label. tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(69,1): error TS7028: Unused label. @@ -11,7 +14,7 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(74,1): error TS7028: Unused label. -==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (11 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (14 errors) ==== // typeof operator on any type var ANY: any; @@ -58,14 +61,20 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator var ResultIsString15 = typeof A.foo(); var ResultIsString16 = typeof (ANY + ANY1); var ResultIsString17 = typeof (null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsString18 = typeof (null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsString19 = typeof (undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple typeof operators var ResultIsString20 = typeof typeof ANY; diff --git a/tests/baselines/reference/voidOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/voidOperatorWithAnyOtherType.errors.txt index 8796f316303..5867a7ad6f5 100644 --- a/tests/baselines/reference/voidOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/voidOperatorWithAnyOtherType.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,34): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,34): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,39): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts (6 errors) ==== // void operator on any type var ANY: any; @@ -50,14 +53,20 @@ tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWith var ResultIsAny15 = void A.foo(); var ResultIsAny16 = void (ANY + ANY1); var ResultIsAny17 = void (null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsAny18 = void (null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsAny19 = void (undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple void operators var ResultIsAny20 = void void ANY; diff --git a/tests/baselines/reference/widenedTypes.errors.txt b/tests/baselines/reference/widenedTypes.errors.txt index 5ea097acf2e..1fd338e6410 100644 --- a/tests/baselines/reference/widenedTypes.errors.txt +++ b/tests/baselines/reference/widenedTypes.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/widenedTypes.ts(2,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. tests/cases/compiler/widenedTypes.ts(6,7): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -tests/cases/compiler/widenedTypes.ts(8,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/compiler/widenedTypes.ts(8,15): error TS2531: Object is possibly 'null'. tests/cases/compiler/widenedTypes.ts(10,14): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/compiler/widenedTypes.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/widenedTypes.ts(18,1): error TS2322: Type '""' is not assignable to type 'number'. @@ -25,7 +25,7 @@ tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ x: number; y: for (var a in null) { } ~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2531: Object is possibly 'null'. var t = [3, (3, null)]; ~ From 8ce193c30295300c7b09d50a73fae770003f41c4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 13 Jan 2017 15:54:39 -0800 Subject: [PATCH 115/175] Improved undefined/null handling for relational operators --- src/compiler/checker.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cb48b2176f9..434dd46d0eb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14585,7 +14585,6 @@ namespace ts { } // NOTE: do not raise error if right is unknown as related error was already reported if (!(isTypeAny(rightType) || - rightType.flags & TypeFlags.Nullable || getSignaturesOfType(rightType, SignatureKind.Call).length || getSignaturesOfType(rightType, SignatureKind.Construct).length || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -14598,6 +14597,8 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. @@ -14952,8 +14953,8 @@ namespace ts { case SyntaxKind.LessThanEqualsToken: case SyntaxKind.GreaterThanEqualsToken: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } From 6dcaac621419d023d6c34b94b2ed8c901e0147dc Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 13 Jan 2017 15:54:50 -0800 Subject: [PATCH 116/175] Accept new baselines --- ...yncFunctionDeclaration10_es2017.errors.txt | 5 +- .../asyncFunctionDeclaration10_es5.errors.txt | 5 +- .../asyncFunctionDeclaration10_es6.errors.txt | 5 +- ...syncFunctionDeclaration5_es2017.errors.txt | 5 +- .../asyncFunctionDeclaration5_es5.errors.txt | 5 +- .../asyncFunctionDeclaration5_es6.errors.txt | 5 +- ...ratorWithIdenticalPrimitiveType.errors.txt | 130 +++++++ ...sonOperatorWithOneOperandIsNull.errors.txt | 360 ++++++++++++++++++ .../reference/equalityStrictNulls.errors.txt | 24 +- .../inOperatorWithInvalidOperands.errors.txt | 16 +- .../reference/widenedTypes.errors.txt | 9 +- 11 files changed, 543 insertions(+), 26 deletions(-) create mode 100644 tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt create mode 100644 tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt index d5da3432264..33cd913a2eb 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (7 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt index dc814e9c887..b974eacd882 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (7 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt index 15ceb3e60c7..b752ec94a45 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt index ad8c0280206..1fc74dfa0a2 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (5 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt index 3060c2c836b..48299773218 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5 tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts (5 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt index a6944e0c6e6..2e907d13400 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (5 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt b/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt new file mode 100644 index 00000000000..ad41a280aad --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt @@ -0,0 +1,130 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(15,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(16,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(24,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(24,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(25,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(25,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(33,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(42,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(42,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(43,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(43,24): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts (16 errors) ==== + enum E { a, b, c } + + var a: number; + var b: boolean; + var c: string; + var d: void; + var e: E; + + // operator < + var ra1 = a < a; + var ra2 = b < b; + var ra3 = c < c; + var ra4 = d < d; + var ra5 = e < e; + var ra6 = null < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra7 = undefined < undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator > + var rb1 = a > a; + var rb2 = b > b; + var rb3 = c > c; + var rb4 = d > d; + var rb5 = e > e; + var rb6 = null > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb7 = undefined > undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator <= + var rc1 = a <= a; + var rc2 = b <= b; + var rc3 = c <= c; + var rc4 = d <= d; + var rc5 = e <= e; + var rc6 = null <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc7 = undefined <= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >= + var rd1 = a >= a; + var rd2 = b >= b; + var rd3 = c >= c; + var rd4 = d >= d; + var rd5 = e >= e; + var rd6 = null >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd7 = undefined >= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator == + var re1 = a == a; + var re2 = b == b; + var re3 = c == c; + var re4 = d == d; + var re5 = e == e; + var re6 = null == null; + var re7 = undefined == undefined; + + // operator != + var rf1 = a != a; + var rf2 = b != b; + var rf3 = c != c; + var rf4 = d != d; + var rf5 = e != e; + var rf6 = null != null; + var rf7 = undefined != undefined; + + // operator === + var rg1 = a === a; + var rg2 = b === b; + var rg3 = c === c; + var rg4 = d === d; + var rg5 = e === e; + var rg6 = null === null; + var rg7 = undefined === undefined; + + // operator !== + var rh1 = a !== a; + var rh2 = b !== b; + var rh3 = c !== c; + var rh4 = d !== d; + var rh5 = e !== e; + var rh6 = null !== null; + var rh7 = undefined !== undefined; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt b/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt new file mode 100644 index 00000000000..c74ab997a59 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt @@ -0,0 +1,360 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(5,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(6,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(7,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(13,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(14,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(15,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(16,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(32,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(33,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(34,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(35,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(36,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(37,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(38,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(40,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(41,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(42,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(43,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(44,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(45,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(46,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(49,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(50,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(51,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(52,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(53,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(54,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(55,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(57,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(58,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(59,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(60,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(61,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(62,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(63,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(66,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(67,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(68,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(69,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(70,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(71,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(72,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(74,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(75,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(76,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(77,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(78,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(79,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(80,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(83,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(84,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(85,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(86,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(87,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(88,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(89,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(91,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(92,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(93,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(94,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(95,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(96,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(97,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts (64 errors) ==== + enum E { a, b, c } + + function foo(t: T) { + var foo_r1 = t < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r2 = t > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r3 = t <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r4 = t >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r5 = t == null; + var foo_r6 = t != null; + var foo_r7 = t === null; + var foo_r8 = t !== null; + + var foo_r1 = null < t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r2 = null > t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r3 = null <= t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r4 = null >= t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r5 = null == t; + var foo_r6 = null != t; + var foo_r7 = null === t; + var foo_r8 = null !== t; + } + + var a: boolean; + var b: number; + var c: string; + var d: void; + var e: E; + var f: {}; + var g: string[]; + + // operator < + var r1a1 = null < a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a2 = null < b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a3 = null < c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a4 = null < d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a5 = null < e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a6 = null < f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a7 = null < g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r1b1 = a < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b2 = b < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b3 = c < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b4 = d < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b5 = e < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b6 = f < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b7 = g < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator > + var r2a1 = null > a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a2 = null > b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a3 = null > c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a4 = null > d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a5 = null > e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a6 = null > f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a7 = null > g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r2b1 = a > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b2 = b > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b3 = c > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b4 = d > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b5 = e > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b6 = f > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b7 = g > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator <= + var r3a1 = null <= a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a2 = null <= b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a3 = null <= c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a4 = null <= d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a5 = null <= e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a6 = null <= f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a7 = null <= g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r3b1 = a <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b2 = b <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b3 = c <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b4 = d <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b5 = e <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b6 = f <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b7 = g <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >= + var r4a1 = null >= a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a2 = null >= b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a3 = null >= c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a4 = null >= d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a5 = null >= e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a6 = null >= f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a7 = null >= g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r4b1 = a >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b2 = b >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b3 = c >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b4 = d >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b5 = e >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b6 = f >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b7 = g >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator == + var r5a1 = null == a; + var r5a2 = null == b; + var r5a3 = null == c; + var r5a4 = null == d; + var r5a5 = null == e; + var r5a6 = null == f; + var r5a7 = null == g; + + var r5b1 = a == null; + var r5b2 = b == null; + var r5b3 = c == null; + var r5b4 = d == null; + var r5b5 = e == null; + var r5b6 = f == null; + var r5b7 = g == null; + + // operator != + var r6a1 = null != a; + var r6a2 = null != b; + var r6a3 = null != c; + var r6a4 = null != d; + var r6a5 = null != e; + var r6a6 = null != f; + var r6a7 = null != g; + + var r6b1 = a != null; + var r6b2 = b != null; + var r6b3 = c != null; + var r6b4 = d != null; + var r6b5 = e != null; + var r6b6 = f != null; + var r6b7 = g != null; + + // operator === + var r7a1 = null === a; + var r7a2 = null === b; + var r7a3 = null === c; + var r7a4 = null === d; + var r7a5 = null === e; + var r7a6 = null === f; + var r7a7 = null === g; + + var r7b1 = a === null; + var r7b2 = b === null; + var r7b3 = c === null; + var r7b4 = d === null; + var r7b5 = e === null; + var r7b6 = f === null; + var r7b7 = g === null; + + // operator !== + var r8a1 = null !== a; + var r8a2 = null !== b; + var r8a3 = null !== c; + var r8a4 = null !== d; + var r8a5 = null !== e; + var r8a6 = null !== f; + var r8a7 = null !== g; + + var r8b1 = a !== null; + var r8b2 = b !== null; + var r8b3 = c !== null; + var r8b4 = d !== null; + var r8b5 = e !== null; + var r8b6 = f !== null; + var r8b7 = g !== null; \ No newline at end of file diff --git a/tests/baselines/reference/equalityStrictNulls.errors.txt b/tests/baselines/reference/equalityStrictNulls.errors.txt index e0793542b84..16772d8eeab 100644 --- a/tests/baselines/reference/equalityStrictNulls.errors.txt +++ b/tests/baselines/reference/equalityStrictNulls.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(60,9): error TS2365: Operator '>' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(62,9): error TS2365: Operator '<' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(64,9): error TS2365: Operator '>=' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(66,9): error TS2365: Operator '<=' cannot be applied to types 'number' and 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(60,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(62,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(64,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(66,14): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts (4 errors) ==== @@ -65,20 +65,20 @@ tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.t function f4(x: number) { if (x > undefined) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x < undefined) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x >= undefined) { - ~~~~~~~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x <= undefined) { - ~~~~~~~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } } function f5(x: string) { diff --git a/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt b/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt index 5aeae5f160e..7615008d89c 100644 --- a/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt @@ -1,6 +1,8 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(12,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(13,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(14,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(16,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(17,11): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(19,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(20,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(30,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter @@ -11,13 +13,13 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(35,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(36,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(37,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(38,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(39,17): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(38,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(39,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(43,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(43,17): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -==== tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts (17 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts (19 errors) ==== enum E { a } var x: any; @@ -40,7 +42,11 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv !!! error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. var ra4 = a4 in x; var ra5 = null in x; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ra6 = undefined in x; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ra7 = E.a in x; var ra8 = false in x; ~~~~~ @@ -83,10 +89,10 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv !!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter var rb9 = x in null; ~~~~ -!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +!!! error TS2531: Object is possibly 'null'. var rb10 = x in undefined; ~~~~~~~~~ -!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +!!! error TS2532: Object is possibly 'undefined'. // both operands are invalid diff --git a/tests/baselines/reference/widenedTypes.errors.txt b/tests/baselines/reference/widenedTypes.errors.txt index 1fd338e6410..f0e3ec33f50 100644 --- a/tests/baselines/reference/widenedTypes.errors.txt +++ b/tests/baselines/reference/widenedTypes.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/widenedTypes.ts(2,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. -tests/cases/compiler/widenedTypes.ts(6,7): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +tests/cases/compiler/widenedTypes.ts(5,1): error TS2531: Object is possibly 'null'. +tests/cases/compiler/widenedTypes.ts(6,7): error TS2531: Object is possibly 'null'. tests/cases/compiler/widenedTypes.ts(8,15): error TS2531: Object is possibly 'null'. tests/cases/compiler/widenedTypes.ts(10,14): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/compiler/widenedTypes.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'. @@ -11,7 +12,7 @@ tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ x: number; y: Type 'number' is not assignable to type 'string'. -==== tests/cases/compiler/widenedTypes.ts (8 errors) ==== +==== tests/cases/compiler/widenedTypes.ts (9 errors) ==== null instanceof (() => { }); ~~~~ @@ -19,9 +20,11 @@ tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ x: number; y: ({}) instanceof null; // Ok because null is a subtype of function null in {}; + ~~~~ +!!! error TS2531: Object is possibly 'null'. "" in null; ~~~~ -!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +!!! error TS2531: Object is possibly 'null'. for (var a in null) { } ~~~~ From 894ba853a080ae33a7a44eab2eec880108850367 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 13 Jan 2017 16:09:03 -0800 Subject: [PATCH 117/175] Improved undefined/null handling for unary operators --- src/compiler/checker.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 434dd46d0eb..8d9b3eb3142 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14483,6 +14483,7 @@ namespace ts { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, TypeFlags.ESSymbol)) { error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator)); } @@ -14494,7 +14495,7 @@ namespace ts { booleanType; case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: - const ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), + const ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -14510,7 +14511,7 @@ namespace ts { if (operandType === silentNeverType) { return silentNeverType; } - const ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), + const ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors From 221c0d7a39a31da863ea13a78e7f3b37f524e93e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 13 Jan 2017 16:09:11 -0800 Subject: [PATCH 118/175] Accept new baselines --- ...bitwiseNotOperatorWithAnyOtherType.errors.txt | 8 +++++++- ...rWithAnyOtherTypeInvalidOperations.errors.txt | 16 +++++++++++----- ...rWithAnyOtherTypeInvalidOperations.errors.txt | 16 +++++++++++----- .../negateOperatorWithAnyOtherType.errors.txt | 8 +++++++- .../plusOperatorWithAnyOtherType.errors.txt | 8 +++++++- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt index 262ac042c68..c3e9f220a3a 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt @@ -1,3 +1,5 @@ +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(35,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(36,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,33): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2531: Object is possibly 'null'. @@ -6,7 +8,7 @@ tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNot tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,38): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (6 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (8 errors) ==== // ~ operator on any type @@ -42,7 +44,11 @@ tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNot // any type literal var ResultIsNumber6 = ~undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber7 = ~null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber8 = ~ANY2[0] diff --git a/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt b/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt index e5456d6f0bd..33e31bc9478 100644 --- a/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt +++ b/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt @@ -9,9 +9,11 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. @@ -56,7 +58,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(72,12): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (56 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (58 errors) ==== // -- operator on any type var ANY1: any; var ANY2: any[] = ["", ""]; @@ -118,14 +120,18 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. var ResultIsNumber12 = --null; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber13 = --undefined; ~~~~~~~~~ !!! error TS2539: Cannot assign to 'undefined' because it is not a variable. var ResultIsNumber14 = null--; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber15 = {}--; ~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt b/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt index bf980bfd153..afdddab86a7 100644 --- a/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt +++ b/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt @@ -9,9 +9,11 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. @@ -51,7 +53,7 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(69,12): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (51 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (53 errors) ==== // ++ operator on any type var ANY1: any; var ANY2: any[] = [1, 2]; @@ -113,14 +115,18 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. var ResultIsNumber12 = ++null; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber13 = ++undefined; ~~~~~~~~~ !!! error TS2539: Cannot assign to 'undefined' because it is not a variable. var ResultIsNumber14 = null++; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber15 = {}++; ~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt index 03e596aca41..0fbf89fb7ec 100644 --- a/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt @@ -1,7 +1,9 @@ +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(35,23): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(51,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts (1 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts (3 errors) ==== // - operator on any type var ANY: any; @@ -36,7 +38,11 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator // any type literal var ResultIsNumber7 = -undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber = -null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber8 = -ANY2[0]; diff --git a/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt index c316cf92e6d..d693aaa17d9 100644 --- a/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt @@ -1,3 +1,5 @@ +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(35,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,33): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'. @@ -7,7 +9,7 @@ tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWith tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(54,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (7 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (9 errors) ==== // + operator on any type var ANY: any; @@ -42,7 +44,11 @@ tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWith // any type literal var ResultIsNumber7 = +undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber8 = +null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber9 = +ANY2[0]; From 33f6fa8cc68786d8fb70ff9b8c9fa107f90733b5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 13 Jan 2017 18:47:18 -0800 Subject: [PATCH 119/175] Error on the return statement itself when checking against function return types. --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a916e9cbba6..80516ef9319 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17922,27 +17922,27 @@ namespace ts { if (func.kind === SyntaxKind.SetAccessor) { if (node.expression) { - error(node.expression, Diagnostics.Setters_cannot_return_a_value); + error(node, Diagnostics.Setters_cannot_return_a_value); } } else if (func.kind === SyntaxKind.Constructor) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (isAsyncFunctionLike(func)) { const promisedType = getPromisedType(returnType); - const awaitedType = checkAwaitedType(exprType, node.expression || node, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + const awaitedType = checkAwaitedType(exprType, node, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType // so we don't need to report one here. - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } From 3ecfc8d0f28ab19c63c215d4a76d538c12b85071 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 13 Jan 2017 18:47:35 -0800 Subject: [PATCH 120/175] Accepted baselines. --- ...rs_spec_section-4.5_error-cases.errors.txt | 8 ++--- .../constructorReturnsInvalidType.errors.txt | 8 ++--- ...rWithAssignableReturnExpression.errors.txt | 16 +++++----- .../derivedGenericClassWithAny.errors.txt | 8 ++--- tests/baselines/reference/fuzzy.errors.txt | 4 +-- .../getSetAccessorContextualTyping.errors.txt | 4 +-- .../reference/inferSetterParamType.errors.txt | 4 +-- .../invalidReturnStatements.errors.txt | 8 ++--- .../matchReturnTypeInAllBranches.errors.txt | 4 +-- .../reference/neverTypeErrors1.errors.txt | 4 +-- .../reference/neverTypeErrors2.errors.txt | 4 +-- .../nonPrimitiveInFunction.errors.txt | 4 +-- .../reference/numberToString.errors.txt | 4 +-- .../reference/objectLiteralErrors.errors.txt | 4 +-- ...rthandPropertiesAssignmentError.errors.txt | 4 +-- ...nmentErrorFromMissingIdentifier.errors.txt | 4 +-- ...OnTypeParameterWithConstraints5.errors.txt | 4 +-- .../recursiveFunctionTypes.errors.txt | 4 +-- .../reference/returnInConstructor1.errors.txt | 32 +++++++++---------- .../reference/returnValueInSetter.errors.txt | 4 +-- .../reference/setterWithReturn.errors.txt | 8 ++--- .../reference/symbolProperty47.errors.txt | 4 +-- .../reference/targetTypeVoidFunc.errors.txt | 4 +-- .../typeGuardFunctionErrors.errors.txt | 16 +++++----- .../typeParameterAssignmentCompat1.errors.txt | 8 ++--- ...ypeParameterHasSelfAsConstraint.errors.txt | 4 +-- 26 files changed, 90 insertions(+), 90 deletions(-) diff --git a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt index 5393eee87d4..278de87e729 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt +++ b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,48): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,47): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -20,13 +20,13 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1 public get AnnotatedSetter_SetterFirst() { return ""; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. public get AnnotatedSetter_SetterLast() { return ""; } ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. public set AnnotatedSetter_SetterLast(a: number) { } ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt index a1a5c5e75b9..a615d7177cf 100644 --- a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt +++ b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type '1' is not assignable to type 'X'. -tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/constructorReturnsInvalidType.ts(3,9): error TS2322: Type '1' is not assignable to type 'X'. +tests/cases/compiler/constructorReturnsInvalidType.ts(3,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/compiler/constructorReturnsInvalidType.ts (2 errors) ==== class X { constructor() { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'X'. - ~ + ~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } foo() { } diff --git a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt index 77c63a217e7..f5948382d64 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type '1' is not assignable to type 'D'. -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2322: Type '{ x: number; }' is not assignable to type 'F'. +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,9): error TS2322: Type '1' is not assignable to type 'D'. +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,9): error TS2322: Type '{ x: number; }' is not assignable to type 'F'. Types of property 'x' are incompatible. Type 'number' is not assignable to type 'T'. -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (4 errors) ==== @@ -19,9 +19,9 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl x: number; constructor() { return 1; // error - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'D'. - ~ + ~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -37,11 +37,11 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl x: T; constructor() { return { x: 1 }; // error - ~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ x: number; }' is not assignable to type 'F'. !!! error TS2322: Types of property 'x' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'T'. - ~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index 81e43f7d8fe..359fab212e9 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -2,8 +2,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,25): error TS2322: Type '""' is not assignable to type 'T'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,16): error TS2322: Type '""' is not assignable to type 'T'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,9): error TS2322: Type '""' is not assignable to type 'T'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(41,1): error TS2322: Type 'E' is not assignable to type 'C'. Types of property 'x' are incompatible. Type 'string' is not assignable to type 'number'. @@ -48,11 +48,11 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC get X(): T { return ''; } // error ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. foo(): T { return ''; // error - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. } } diff --git a/tests/baselines/reference/fuzzy.errors.txt b/tests/baselines/reference/fuzzy.errors.txt index 19f0ad56a5e..c3f05fd7f2f 100644 --- a/tests/baselines/reference/fuzzy.errors.txt +++ b/tests/baselines/reference/fuzzy.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/fuzzy.ts(13,18): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'alsoWorks' is missing in type 'C'. -tests/cases/compiler/fuzzy.ts(21,20): error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. +tests/cases/compiler/fuzzy.ts(21,13): error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. Types of property 'oneI' are incompatible. Type 'this' is not assignable to type 'I'. Type 'C' is not assignable to type 'I'. @@ -33,7 +33,7 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' canno doesntWork():R { return { anything:1, oneI:this }; - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. !!! error TS2322: Types of property 'oneI' are incompatible. !!! error TS2322: Type 'this' is not assignable to type 'I'. diff --git a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt index 845a4011d9f..dc77d530e01 100644 --- a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt +++ b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,16): error TS2322: Type '"string"' is not assignable to type 'number'. +tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,9): error TS2322: Type '"string"' is not assignable to type 'number'. ==== tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyp set X(x: number) { } get X() { return "string"; // Error; get contextual type by set accessor parameter type annotation - ~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2322: Type '"string"' is not assignable to type 'number'. } diff --git a/tests/baselines/reference/inferSetterParamType.errors.txt b/tests/baselines/reference/inferSetterParamType.errors.txt index 02c02ba69d5..7b28c52d48b 100644 --- a/tests/baselines/reference/inferSetterParamType.errors.txt +++ b/tests/baselines/reference/inferSetterParamType.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/inferSetterParamType.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inferSetterParamType.ts(13,16): error TS2322: Type '0' is not assignable to type 'string'. +tests/cases/compiler/inferSetterParamType.ts(13,9): error TS2322: Type '0' is not assignable to type 'string'. tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -25,7 +25,7 @@ tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return 0; // should be an error - can't coerce infered return type to match setter annotated type - ~ + ~~~~~~~~~ !!! error TS2322: Type '0' is not assignable to type 'string'. } set bar(n:string) { diff --git a/tests/baselines/reference/invalidReturnStatements.errors.txt b/tests/baselines/reference/invalidReturnStatements.errors.txt index 6fbe961cd54..0f51e75a47d 100644 --- a/tests/baselines/reference/invalidReturnStatements.errors.txt +++ b/tests/baselines/reference/invalidReturnStatements.errors.txt @@ -2,9 +2,9 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(2 tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(4,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(5,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(16,29): error TS2322: Type '{ id: number; }' is not assignable to type 'D'. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(16,22): error TS2322: Type '{ id: number; }' is not assignable to type 'D'. Property 'name' is missing in type '{ id: number; }'. -tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(18,29): error TS2322: Type 'C' is not assignable to type 'D'. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(18,22): error TS2322: Type 'C' is not assignable to type 'D'. Property 'name' is missing in type 'C'. @@ -33,12 +33,12 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(1 name: string; } function fn10(): D { return { id: 12 }; } - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ id: number; }' is not assignable to type 'D'. !!! error TS2322: Property 'name' is missing in type '{ id: number; }'. function fn11(): D { return new C(); } - ~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'C' is not assignable to type 'D'. !!! error TS2322: Property 'name' is missing in type 'C'. diff --git a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt index 405fa4d2036..6cf1bbc5fa3 100644 --- a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt +++ b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type '12345' is not assignable to type 'boolean'. +tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,13): error TS2322: Type '12345' is not assignable to type 'boolean'. ==== tests/cases/compiler/matchReturnTypeInAllBranches.ts (1 errors) ==== @@ -32,7 +32,7 @@ tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type else { return 12345; - ~~~~~ + ~~~~~~~~~~~~~ !!! error TS2322: Type '12345' is not assignable to type 'boolean'. } } diff --git a/tests/baselines/reference/neverTypeErrors1.errors.txt b/tests/baselines/reference/neverTypeErrors1.errors.txt index cb79c0c19fb..a27c6fba065 100644 --- a/tests/baselines/reference/neverTypeErrors1.errors.txt +++ b/tests/baselines/reference/neverTypeErrors1.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(6,5): error TS2322: Type tests/cases/conformance/types/never/neverTypeErrors1.ts(7,5): error TS2322: Type 'null' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(8,5): error TS2322: Type '{}' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(12,5): error TS2322: Type 'undefined' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors1.ts(16,12): error TS2322: Type '1' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors1.ts(16,5): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -40,7 +40,7 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A function f3(): never { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'never'. } diff --git a/tests/baselines/reference/neverTypeErrors2.errors.txt b/tests/baselines/reference/neverTypeErrors2.errors.txt index ed27e615ea1..60e6947f44a 100644 --- a/tests/baselines/reference/neverTypeErrors2.errors.txt +++ b/tests/baselines/reference/neverTypeErrors2.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(7,5): error TS2322: Type tests/cases/conformance/types/never/neverTypeErrors2.ts(8,5): error TS2322: Type 'null' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(9,5): error TS2322: Type '{}' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(13,5): error TS2322: Type 'undefined' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors2.ts(17,12): error TS2322: Type '1' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors2.ts(17,5): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -41,7 +41,7 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function f3(): never { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'never'. } diff --git a/tests/baselines/reference/nonPrimitiveInFunction.errors.txt b/tests/baselines/reference/nonPrimitiveInFunction.errors.txt index 5ca231b61c8..c7f89fbdd06 100644 --- a/tests/baselines/reference/nonPrimitiveInFunction.errors.txt +++ b/tests/baselines/reference/nonPrimitiveInFunction.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(12,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(13,1): error TS2322: Type 'object' is not assignable to type 'boolean'. -tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(17,12): error TS2322: Type 'number' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(17,5): error TS2322: Type 'number' is not assignable to type 'object'. ==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts (3 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(17,12): err function returnError(): object { var ret = 123; return ret; // expect error - ~~~ + ~~~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'object'. } \ No newline at end of file diff --git a/tests/baselines/reference/numberToString.errors.txt b/tests/baselines/reference/numberToString.errors.txt index 60a382e47c3..bbd9178862a 100644 --- a/tests/baselines/reference/numberToString.errors.txt +++ b/tests/baselines/reference/numberToString.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/numberToString.ts(2,12): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/numberToString.ts(2,5): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/compiler/numberToString.ts(9,4): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/numberToString.ts (2 errors) ==== function f1(n:number):string { return n; // error return type mismatch - ~ + ~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. } diff --git a/tests/baselines/reference/objectLiteralErrors.errors.txt b/tests/baselines/reference/objectLiteralErrors.errors.txt index 03b4b74eacd..0e0db0b414f 100644 --- a/tests/baselines/reference/objectLiteralErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralErrors.errors.txt @@ -73,7 +73,7 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46) tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46): error TS2300: Duplicate identifier 'a'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,16): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,47): error TS2380: 'get' and 'set' accessor must have the same type. -tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,29): error TS2322: Type '4' is not assignable to type 'string'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,22): error TS2322: Type '4' is not assignable to type 'string'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,16): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55): error TS2380: 'get' and 'set' accessor must have the same type. @@ -273,7 +273,7 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55) ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. var g2 = { get a() { return 4; }, set a(n: string) { } }; - ~ + ~~~~~~~~~ !!! error TS2322: Type '4' is not assignable to type 'string'. var g3 = { get a(): number { return undefined; }, set a(n: string) { } }; ~ diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index 6f405facceb..c0e6e10d8de 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,72): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. Types of property 'id' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'. @@ -18,7 +18,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. var person1: { name, id }; // ok function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error - ~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. !!! error TS2322: Types of property 'id' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt index 92750fd29a0..6b227fce710 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,72): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. Types of property 'name' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(8,5): error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'. @@ -17,7 +17,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error - ~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. !!! error TS2322: Types of property 'name' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt index fd012d0e5a5..c1052dff554 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(15,32): error TS2339: Property 'notHere' does not exist on type 'U'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(25,16): error TS2339: Property 'notHere' does not exist on type 'B'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(32,22): error TS2339: Property 'notHere' does not exist on type 'A'. -tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,16): error TS2322: Type 'string' is not assignable to type 'U'. +tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,9): error TS2322: Type 'string' is not assignable to type 'U'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,22): error TS2339: Property 'notHere' does not exist on type 'U'. @@ -50,7 +50,7 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOn foo: (x: U): U => { var a = x['foo'](); // should be string return a + x.notHere(); - ~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'U'. ~~~~~~~ !!! error TS2339: Property 'notHere' does not exist on type 'U'. diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index 8614f747016..8a454133a82 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/recursiveFunctionTypes.ts(1,35): error TS2322: Type '1' is not assignable to type '() => typeof fn'. +tests/cases/compiler/recursiveFunctionTypes.ts(1,28): error TS2322: Type '1' is not assignable to type '() => typeof fn'. tests/cases/compiler/recursiveFunctionTypes.ts(3,5): error TS2322: Type '() => typeof fn' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(4,5): error TS2322: Type '() => typeof fn' is not assignable to type '() => number'. Type '() => typeof fn' is not assignable to type 'number'. @@ -16,7 +16,7 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of ==== tests/cases/compiler/recursiveFunctionTypes.ts (13 errors) ==== function fn(): typeof fn { return 1; } - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type '() => typeof fn'. var x: number = fn; // error diff --git a/tests/baselines/reference/returnInConstructor1.errors.txt b/tests/baselines/reference/returnInConstructor1.errors.txt index a7d3fd05204..939d303ec65 100644 --- a/tests/baselines/reference/returnInConstructor1.errors.txt +++ b/tests/baselines/reference/returnInConstructor1.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2322: Type '1' is not assignable to type 'B'. -tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2322: Type '"test"' is not assignable to type 'D'. -tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. +tests/cases/compiler/returnInConstructor1.ts(11,9): error TS2322: Type '1' is not assignable to type 'B'. +tests/cases/compiler/returnInConstructor1.ts(11,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(25,9): error TS2322: Type '"test"' is not assignable to type 'D'. +tests/cases/compiler/returnInConstructor1.ts(25,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(39,9): error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. Types of property 'foo' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2322: Type 'G' is not assignable to type 'H'. +tests/cases/compiler/returnInConstructor1.ts(39,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(55,9): error TS2322: Type 'G' is not assignable to type 'H'. Types of property 'foo' are incompatible. Type '() => void' is not assignable to type 'string'. -tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(55,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/compiler/returnInConstructor1.ts (8 errors) ==== @@ -24,9 +24,9 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o foo() { } constructor() { return 1; // error - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'B'. - ~ + ~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -42,9 +42,9 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o foo() { } constructor() { return "test"; // error - ~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS2322: Type '"test"' is not assignable to type 'D'. - ~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -60,11 +60,11 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o public foo: string; constructor() { return { foo: 1 }; //error - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -82,11 +82,11 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o constructor() { super(); return new G(); //error - ~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'G' is not assignable to type 'H'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type '() => void' is not assignable to type 'string'. - ~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } diff --git a/tests/baselines/reference/returnValueInSetter.errors.txt b/tests/baselines/reference/returnValueInSetter.errors.txt index f9dffa1bc36..4d7b0d185f9 100644 --- a/tests/baselines/reference/returnValueInSetter.errors.txt +++ b/tests/baselines/reference/returnValueInSetter.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/returnValueInSetter.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/returnValueInSetter.ts(3,16): error TS2408: Setters cannot return a value. +tests/cases/compiler/returnValueInSetter.ts(3,9): error TS2408: Setters cannot return a value. ==== tests/cases/compiler/returnValueInSetter.ts (2 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/returnValueInSetter.ts(3,16): error TS2408: Setters cannot ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return null; // Should be an error - ~~~~ + ~~~~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } } diff --git a/tests/baselines/reference/setterWithReturn.errors.txt b/tests/baselines/reference/setterWithReturn.errors.txt index 6aed49105b8..a0f04506a71 100644 --- a/tests/baselines/reference/setterWithReturn.errors.txt +++ b/tests/baselines/reference/setterWithReturn.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/setterWithReturn.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/setterWithReturn.ts(4,20): error TS2408: Setters cannot return a value. +tests/cases/compiler/setterWithReturn.ts(4,13): error TS2408: Setters cannot return a value. tests/cases/compiler/setterWithReturn.ts(7,13): error TS7027: Unreachable code detected. -tests/cases/compiler/setterWithReturn.ts(7,20): error TS2408: Setters cannot return a value. +tests/cases/compiler/setterWithReturn.ts(7,13): error TS2408: Setters cannot return a value. ==== tests/cases/compiler/setterWithReturn.ts (4 errors) ==== @@ -11,14 +11,14 @@ tests/cases/compiler/setterWithReturn.ts(7,20): error TS2408: Setters cannot ret !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. if (true) { return arg1; - ~~~~ + ~~~~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } else { return 0; ~~~~~~ !!! error TS7027: Unreachable code detected. - ~ + ~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } } diff --git a/tests/baselines/reference/symbolProperty47.errors.txt b/tests/baselines/reference/symbolProperty47.errors.txt index 2e15085eb24..143d2405d0b 100644 --- a/tests/baselines/reference/symbolProperty47.errors.txt +++ b/tests/baselines/reference/symbolProperty47.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty47.ts(3,16): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty47.ts(3,9): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'. @@ -6,7 +6,7 @@ tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Typ class C { get [Symbol.hasInstance]() { return ""; - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. } // Should take a string diff --git a/tests/baselines/reference/targetTypeVoidFunc.errors.txt b/tests/baselines/reference/targetTypeVoidFunc.errors.txt index d47f811c2ed..6c0efe288bd 100644 --- a/tests/baselines/reference/targetTypeVoidFunc.errors.txt +++ b/tests/baselines/reference/targetTypeVoidFunc.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/targetTypeVoidFunc.ts(2,12): error TS2322: Type '() => void' is not assignable to type 'new () => number'. +tests/cases/compiler/targetTypeVoidFunc.ts(2,5): error TS2322: Type '() => void' is not assignable to type 'new () => number'. Type '() => void' provides no match for the signature 'new (): number' ==== tests/cases/compiler/targetTypeVoidFunc.ts (1 errors) ==== function f1(): { new (): number; } { return function () { return; } - ~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'new () => number'. !!! error TS2322: Type '() => void' provides no match for the signature 'new (): number' }; diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 88f71cda196..e9dfbf5bf27 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(2,7): error TS2300: Duplicate identifier 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type '""' is not assignable to type 'boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,5): error TS2322: Type '""' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,55): error TS2304: Cannot find name 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS1144: '{' or ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS2304: Cannot find name 'is'. @@ -47,11 +47,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,27): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2322: Type 'true' is not assignable to type 'D'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,9): error TS2322: Type 'true' is not assignable to type 'D'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,16): error TS2408: Setters cannot return a value. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,9): error TS2408: Setters cannot return a value. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,22): error TS2304: Cannot find name 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,25): error TS1005: ';' expected. @@ -82,7 +82,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 function hasANonBooleanReturnStatement(x): x is A { return ''; - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'boolean'. } @@ -258,9 +258,9 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 ~~~~~~~ !!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; - ~~~~ + ~~~~~~~~~~~~ !!! error TS2322: Type 'true' is not assignable to type 'D'. - ~~~~ + ~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } get m1(p1: A): p1 is C { @@ -272,7 +272,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 ~~~~~~~ !!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; - ~~~~ + ~~~~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } } diff --git a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt index d3bc25c00b1..9665ef017c0 100644 --- a/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt +++ b/tests/baselines/reference/typeParameterAssignmentCompat1.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(8,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'T'. -tests/cases/compiler/typeParameterAssignmentCompat1.ts(9,12): error TS2322: Type 'Foo' is not assignable to type 'Foo'. +tests/cases/compiler/typeParameterAssignmentCompat1.ts(9,5): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'T' is not assignable to type 'U'. tests/cases/compiler/typeParameterAssignmentCompat1.ts(16,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'T'. -tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,16): error TS2322: Type 'Foo' is not assignable to type 'Foo'. +tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,9): error TS2322: Type 'Foo' is not assignable to type 'Foo'. Type 'T' is not assignable to type 'U'. @@ -21,7 +21,7 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,16): error TS2322: Typ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'U' is not assignable to type 'T'. return x; - ~ + ~~~~~~~~~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'T' is not assignable to type 'U'. } @@ -35,7 +35,7 @@ tests/cases/compiler/typeParameterAssignmentCompat1.ts(17,16): error TS2322: Typ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'U' is not assignable to type 'T'. return x; - ~ + ~~~~~~~~~ !!! error TS2322: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2322: Type 'T' is not assignable to type 'U'. } diff --git a/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt b/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt index b459534080f..01cfff63e5f 100644 --- a/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt +++ b/tests/baselines/reference/typeParameterHasSelfAsConstraint.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(1,24): error TS2313: Type parameter 'T' has a circular constraint. -tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(2,12): error TS2322: Type 'T' is not assignable to type 'number'. +tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(2,5): error TS2322: Type 'T' is not assignable to type 'number'. ==== tests/cases/compiler/typeParameterHasSelfAsConstraint.ts (2 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/typeParameterHasSelfAsConstraint.ts(2,12): error TS2322: Ty ~ !!! error TS2313: Type parameter 'T' has a circular constraint. return x; - ~ + ~~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'number'. } From 093929e49ced5d4207f69b4de822dff03103505d Mon Sep 17 00:00:00 2001 From: rdosanjh Date: Sat, 14 Jan 2017 11:02:05 +0000 Subject: [PATCH 121/175] adding 2 new lines to tsc --watch output --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a7304eebe4b..866065af972 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -155,7 +155,7 @@ namespace ts { output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; } - output += `${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; + output += `${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine + sys.newLine + sys.newLine }`; sys.write(output); } From 4718efd181c2ddcc7d1203cb6ec13367ab4537b3 Mon Sep 17 00:00:00 2001 From: about-code Date: Sat, 14 Jan 2017 16:06:13 +0100 Subject: [PATCH 122/175] Removing es6 method/property distinction. Adding tests with default export and anonymous class expressions. --- .../staticPropertyNameConflicts.errors.txt | 293 ++++++++++++ .../reference/staticPropertyNameConflicts.js | 429 ++++++++++++++++++ ...sEs5.ts => staticPropertyNameConflicts.ts} | 0 .../staticPropertyNameConflictsEs6.ts | 56 --- 4 files changed, 722 insertions(+), 56 deletions(-) create mode 100644 tests/baselines/reference/staticPropertyNameConflicts.errors.txt create mode 100644 tests/baselines/reference/staticPropertyNameConflicts.js rename tests/cases/conformance/classes/propertyMemberDeclarations/{staticPropertyNameConflictsEs5.ts => staticPropertyNameConflicts.ts} (100%) delete mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts diff --git a/tests/baselines/reference/staticPropertyNameConflicts.errors.txt b/tests/baselines/reference/staticPropertyNameConflicts.errors.txt new file mode 100644 index 00000000000..4c051ace0ac --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflicts.errors.txt @@ -0,0 +1,293 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(3,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(8,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(14,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(19,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(25,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(30,12): error TS2300: Duplicate identifier 'prototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(30,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(36,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(41,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(47,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(52,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(62,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(67,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(73,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(78,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(84,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(89,12): error TS2300: Duplicate identifier 'prototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(89,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(95,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(100,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(106,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(111,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function '(Anonymous class)'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(121,16): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(128,16): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(136,16): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(143,16): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(151,16): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(158,16): error TS2300: Duplicate identifier 'prototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(158,16): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(166,16): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(173,16): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(181,16): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(188,16): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts (33 errors) ==== + // name + class StaticName { + static name: number; // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. + name: string; // ok + } + + class StaticNameFn { + static name() {} // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. + name() {} // ok + } + + // length + class StaticLength { + static length: number; // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. + length: string; // ok + } + + class StaticLengthFn { + static length() {} // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. + length() {} // ok + } + + // prototype + class StaticPrototype { + static prototype: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. + prototype: string; // ok + } + + class StaticPrototypeFn { + static prototype() {} // error + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. + prototype() {} // ok + } + + // caller + class StaticCaller { + static caller: number; // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. + caller: string; // ok + } + + class StaticCallerFn { + static caller() {} // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. + caller() {} // ok + } + + // arguments + class StaticArguments { + static arguments: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. + arguments: string; // ok + } + + class StaticArgumentsFn { + static arguments() {} // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + arguments() {} // ok + } + + + + // === Static properties on anonymous classes === + + // name + var StaticName_Anonymous = class { + static name: number; // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function '(Anonymous class)'. + name: string; // ok + } + + var StaticNameFn_Anonymous = class { + static name() {} // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function '(Anonymous class)'. + name() {} // ok + } + + // length + var StaticLength_Anonymous = class { + static length: number; // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function '(Anonymous class)'. + length: string; // ok + } + + var StaticLengthFn_Anonymous = class { + static length() {} // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function '(Anonymous class)'. + length() {} // ok + } + + // prototype + var StaticPrototype_Anonymous = class { + static prototype: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function '(Anonymous class)'. + prototype: string; // ok + } + + var StaticPrototypeFn_Anonymous = class { + static prototype() {} // error + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function '(Anonymous class)'. + prototype() {} // ok + } + + // caller + var StaticCaller_Anonymous = class { + static caller: number; // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function '(Anonymous class)'. + caller: string; // ok + } + + var StaticCallerFn_Anonymous = class { + static caller() {} // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function '(Anonymous class)'. + caller() {} // ok + } + + // arguments + var StaticArguments_Anonymous = class { + static arguments: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function '(Anonymous class)'. + arguments: string; // ok + } + + var StaticArgumentsFn_Anonymous = class { + static arguments() {} // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function '(Anonymous class)'. + arguments() {} // ok + } + + + // === Static properties on default exported classes === + + // name + module TestOnDefaultExportedClass_1 { + class StaticName { + static name: number; // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. + name: string; // ok + } + } + + module TestOnDefaultExportedClass_2 { + class StaticNameFn { + static name() {} // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. + name() {} // ok + } + } + + // length + module TestOnDefaultExportedClass_3 { + export default class StaticLength { + static length: number; // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. + length: string; // ok + } + } + + module TestOnDefaultExportedClass_4 { + export default class StaticLengthFn { + static length() {} // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. + length() {} // ok + } + } + + // prototype + module TestOnDefaultExportedClass_5 { + export default class StaticPrototype { + static prototype: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. + prototype: string; // ok + } + } + + module TestOnDefaultExportedClass_6 { + export default class StaticPrototypeFn { + static prototype() {} // error + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. + prototype() {} // ok + } + } + + // caller + module TestOnDefaultExportedClass_7 { + export default class StaticCaller { + static caller: number; // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. + caller: string; // ok + } + } + + module TestOnDefaultExportedClass_8 { + export default class StaticCallerFn { + static caller() {} // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. + caller() {} // ok + } + } + + // arguments + module TestOnDefaultExportedClass_9 { + export default class StaticArguments { + static arguments: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. + arguments: string; // ok + } + } + + module TestOnDefaultExportedClass_10 { + export default class StaticArgumentsFn { + static arguments() {} // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + arguments() {} // ok + } + } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflicts.js b/tests/baselines/reference/staticPropertyNameConflicts.js new file mode 100644 index 00000000000..b93b16550f0 --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflicts.js @@ -0,0 +1,429 @@ +//// [staticPropertyNameConflicts.ts] +// name +class StaticName { + static name: number; // error + name: string; // ok +} + +class StaticNameFn { + static name() {} // error + name() {} // ok +} + +// length +class StaticLength { + static length: number; // error + length: string; // ok +} + +class StaticLengthFn { + static length() {} // error + length() {} // ok +} + +// prototype +class StaticPrototype { + static prototype: number; // error + prototype: string; // ok +} + +class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok +} + +// caller +class StaticCaller { + static caller: number; // error + caller: string; // ok +} + +class StaticCallerFn { + static caller() {} // error + caller() {} // ok +} + +// arguments +class StaticArguments { + static arguments: number; // error + arguments: string; // ok +} + +class StaticArgumentsFn { + static arguments() {} // error + arguments() {} // ok +} + + + +// === Static properties on anonymous classes === + +// name +var StaticName_Anonymous = class { + static name: number; // error + name: string; // ok +} + +var StaticNameFn_Anonymous = class { + static name() {} // error + name() {} // ok +} + +// length +var StaticLength_Anonymous = class { + static length: number; // error + length: string; // ok +} + +var StaticLengthFn_Anonymous = class { + static length() {} // error + length() {} // ok +} + +// prototype +var StaticPrototype_Anonymous = class { + static prototype: number; // error + prototype: string; // ok +} + +var StaticPrototypeFn_Anonymous = class { + static prototype() {} // error + prototype() {} // ok +} + +// caller +var StaticCaller_Anonymous = class { + static caller: number; // error + caller: string; // ok +} + +var StaticCallerFn_Anonymous = class { + static caller() {} // error + caller() {} // ok +} + +// arguments +var StaticArguments_Anonymous = class { + static arguments: number; // error + arguments: string; // ok +} + +var StaticArgumentsFn_Anonymous = class { + static arguments() {} // error + arguments() {} // ok +} + + +// === Static properties on default exported classes === + +// name +module TestOnDefaultExportedClass_1 { + class StaticName { + static name: number; // error + name: string; // ok + } +} + +module TestOnDefaultExportedClass_2 { + class StaticNameFn { + static name() {} // error + name() {} // ok + } +} + +// length +module TestOnDefaultExportedClass_3 { + export default class StaticLength { + static length: number; // error + length: string; // ok + } +} + +module TestOnDefaultExportedClass_4 { + export default class StaticLengthFn { + static length() {} // error + length() {} // ok + } +} + +// prototype +module TestOnDefaultExportedClass_5 { + export default class StaticPrototype { + static prototype: number; // error + prototype: string; // ok + } +} + +module TestOnDefaultExportedClass_6 { + export default class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok + } +} + +// caller +module TestOnDefaultExportedClass_7 { + export default class StaticCaller { + static caller: number; // error + caller: string; // ok + } +} + +module TestOnDefaultExportedClass_8 { + export default class StaticCallerFn { + static caller() {} // error + caller() {} // ok + } +} + +// arguments +module TestOnDefaultExportedClass_9 { + export default class StaticArguments { + static arguments: number; // error + arguments: string; // ok + } +} + +module TestOnDefaultExportedClass_10 { + export default class StaticArgumentsFn { + static arguments() {} // error + arguments() {} // ok + } +} + +//// [staticPropertyNameConflicts.js] +// name +var StaticName = (function () { + function StaticName() { + } + return StaticName; +}()); +var StaticNameFn = (function () { + function StaticNameFn() { + } + StaticNameFn.name = function () { }; // error + StaticNameFn.prototype.name = function () { }; // ok + return StaticNameFn; +}()); +// length +var StaticLength = (function () { + function StaticLength() { + } + return StaticLength; +}()); +var StaticLengthFn = (function () { + function StaticLengthFn() { + } + StaticLengthFn.length = function () { }; // error + StaticLengthFn.prototype.length = function () { }; // ok + return StaticLengthFn; +}()); +// prototype +var StaticPrototype = (function () { + function StaticPrototype() { + } + return StaticPrototype; +}()); +var StaticPrototypeFn = (function () { + function StaticPrototypeFn() { + } + StaticPrototypeFn.prototype = function () { }; // error + StaticPrototypeFn.prototype.prototype = function () { }; // ok + return StaticPrototypeFn; +}()); +// caller +var StaticCaller = (function () { + function StaticCaller() { + } + return StaticCaller; +}()); +var StaticCallerFn = (function () { + function StaticCallerFn() { + } + StaticCallerFn.caller = function () { }; // error + StaticCallerFn.prototype.caller = function () { }; // ok + return StaticCallerFn; +}()); +// arguments +var StaticArguments = (function () { + function StaticArguments() { + } + return StaticArguments; +}()); +var StaticArgumentsFn = (function () { + function StaticArgumentsFn() { + } + StaticArgumentsFn.arguments = function () { }; // error + StaticArgumentsFn.prototype.arguments = function () { }; // ok + return StaticArgumentsFn; +}()); +// === Static properties on anonymous classes === +// name +var StaticName_Anonymous = (function () { + function class_1() { + } + return class_1; +}()); +var StaticNameFn_Anonymous = (function () { + function class_2() { + } + class_2.name = function () { }; // error + class_2.prototype.name = function () { }; // ok + return class_2; +}()); +// length +var StaticLength_Anonymous = (function () { + function class_3() { + } + return class_3; +}()); +var StaticLengthFn_Anonymous = (function () { + function class_4() { + } + class_4.length = function () { }; // error + class_4.prototype.length = function () { }; // ok + return class_4; +}()); +// prototype +var StaticPrototype_Anonymous = (function () { + function class_5() { + } + return class_5; +}()); +var StaticPrototypeFn_Anonymous = (function () { + function class_6() { + } + class_6.prototype = function () { }; // error + class_6.prototype.prototype = function () { }; // ok + return class_6; +}()); +// caller +var StaticCaller_Anonymous = (function () { + function class_7() { + } + return class_7; +}()); +var StaticCallerFn_Anonymous = (function () { + function class_8() { + } + class_8.caller = function () { }; // error + class_8.prototype.caller = function () { }; // ok + return class_8; +}()); +// arguments +var StaticArguments_Anonymous = (function () { + function class_9() { + } + return class_9; +}()); +var StaticArgumentsFn_Anonymous = (function () { + function class_10() { + } + class_10.arguments = function () { }; // error + class_10.prototype.arguments = function () { }; // ok + return class_10; +}()); +// === Static properties on default exported classes === +// name +var TestOnDefaultExportedClass_1; +(function (TestOnDefaultExportedClass_1) { + var StaticName = (function () { + function StaticName() { + } + return StaticName; + }()); +})(TestOnDefaultExportedClass_1 || (TestOnDefaultExportedClass_1 = {})); +var TestOnDefaultExportedClass_2; +(function (TestOnDefaultExportedClass_2) { + var StaticNameFn = (function () { + function StaticNameFn() { + } + StaticNameFn.name = function () { }; // error + StaticNameFn.prototype.name = function () { }; // ok + return StaticNameFn; + }()); +})(TestOnDefaultExportedClass_2 || (TestOnDefaultExportedClass_2 = {})); +// length +var TestOnDefaultExportedClass_3; +(function (TestOnDefaultExportedClass_3) { + var StaticLength = (function () { + function StaticLength() { + } + return StaticLength; + }()); + TestOnDefaultExportedClass_3.StaticLength = StaticLength; +})(TestOnDefaultExportedClass_3 || (TestOnDefaultExportedClass_3 = {})); +var TestOnDefaultExportedClass_4; +(function (TestOnDefaultExportedClass_4) { + var StaticLengthFn = (function () { + function StaticLengthFn() { + } + StaticLengthFn.length = function () { }; // error + StaticLengthFn.prototype.length = function () { }; // ok + return StaticLengthFn; + }()); + TestOnDefaultExportedClass_4.StaticLengthFn = StaticLengthFn; +})(TestOnDefaultExportedClass_4 || (TestOnDefaultExportedClass_4 = {})); +// prototype +var TestOnDefaultExportedClass_5; +(function (TestOnDefaultExportedClass_5) { + var StaticPrototype = (function () { + function StaticPrototype() { + } + return StaticPrototype; + }()); + TestOnDefaultExportedClass_5.StaticPrototype = StaticPrototype; +})(TestOnDefaultExportedClass_5 || (TestOnDefaultExportedClass_5 = {})); +var TestOnDefaultExportedClass_6; +(function (TestOnDefaultExportedClass_6) { + var StaticPrototypeFn = (function () { + function StaticPrototypeFn() { + } + StaticPrototypeFn.prototype = function () { }; // error + StaticPrototypeFn.prototype.prototype = function () { }; // ok + return StaticPrototypeFn; + }()); + TestOnDefaultExportedClass_6.StaticPrototypeFn = StaticPrototypeFn; +})(TestOnDefaultExportedClass_6 || (TestOnDefaultExportedClass_6 = {})); +// caller +var TestOnDefaultExportedClass_7; +(function (TestOnDefaultExportedClass_7) { + var StaticCaller = (function () { + function StaticCaller() { + } + return StaticCaller; + }()); + TestOnDefaultExportedClass_7.StaticCaller = StaticCaller; +})(TestOnDefaultExportedClass_7 || (TestOnDefaultExportedClass_7 = {})); +var TestOnDefaultExportedClass_8; +(function (TestOnDefaultExportedClass_8) { + var StaticCallerFn = (function () { + function StaticCallerFn() { + } + StaticCallerFn.caller = function () { }; // error + StaticCallerFn.prototype.caller = function () { }; // ok + return StaticCallerFn; + }()); + TestOnDefaultExportedClass_8.StaticCallerFn = StaticCallerFn; +})(TestOnDefaultExportedClass_8 || (TestOnDefaultExportedClass_8 = {})); +// arguments +var TestOnDefaultExportedClass_9; +(function (TestOnDefaultExportedClass_9) { + var StaticArguments = (function () { + function StaticArguments() { + } + return StaticArguments; + }()); + TestOnDefaultExportedClass_9.StaticArguments = StaticArguments; +})(TestOnDefaultExportedClass_9 || (TestOnDefaultExportedClass_9 = {})); +var TestOnDefaultExportedClass_10; +(function (TestOnDefaultExportedClass_10) { + var StaticArgumentsFn = (function () { + function StaticArgumentsFn() { + } + StaticArgumentsFn.arguments = function () { }; // error + StaticArgumentsFn.prototype.arguments = function () { }; // ok + return StaticArgumentsFn; + }()); + TestOnDefaultExportedClass_10.StaticArgumentsFn = StaticArgumentsFn; +})(TestOnDefaultExportedClass_10 || (TestOnDefaultExportedClass_10 = {})); diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts similarity index 100% rename from tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts rename to tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts deleted file mode 100644 index 1b93e98dae8..00000000000 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts +++ /dev/null @@ -1,56 +0,0 @@ -// @target: es6 - - -class StaticName { - static name: number; // error - name: string; // ok -} - -class StaticNameFn { - static name() {} // ok - name() {} // ok -} - - -class StaticLength { - static length: number; // error - length: string; // ok -} - -class StaticLengthFn { - static length() {} // ok - length() {} // ok -} - - -class StaticPrototype { - static prototype: number; // error - prototype: string; // ok -} - -class StaticPrototypeFn { - static prototype() {} // error - prototype() {} // ok -} - - -class StaticCaller { - static caller: number; // error - caller: string; // ok -} - -class StaticCallerFn { - static caller() {} // ok - caller() {} // ok -} - - -class StaticArguments { - static arguments: number; // error - arguments: string; // ok -} - -class StaticArgumentsFn { - static arguments() {} // ok - arguments() {} // ok -} From 9b217e31df0898c229619f1e7465225f97ed5720 Mon Sep 17 00:00:00 2001 From: about-code Date: Sat, 14 Jan 2017 16:30:12 +0100 Subject: [PATCH 123/175] Removing es6 method/property distinction. Adding tests with default export and anonymous class expressions. --- src/compiler/checker.ts | 40 ++--- .../staticPropertyNameConflictsEs5.errors.txt | 92 ----------- .../staticPropertyNameConflictsEs5.js | 120 -------------- .../staticPropertyNameConflictsEs6.errors.txt | 80 ---------- .../staticPropertyNameConflictsEs6.js | 89 ----------- .../staticPropertyNameConflicts.ts | 150 +++++++++++++++++- 6 files changed, 155 insertions(+), 416 deletions(-) delete mode 100644 tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt delete mode 100644 tests/baselines/reference/staticPropertyNameConflictsEs5.js delete mode 100644 tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt delete mode 100644 tests/baselines/reference/staticPropertyNameConflictsEs6.js diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 884860d6b14..da6235b6d1c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15694,8 +15694,8 @@ namespace ts { } /** - * Static members being set on a constructor function may conflict with built-in Function - * object properties. Esp. in ECMAScript 5 there are non-configurable and non-writable + * Static members being set on a constructor function may conflict with built-in properties + * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable * built-in properties. This check issues a transpile error when a class has a static * member with the same name as a non-writable built-in property. * @@ -15705,37 +15705,21 @@ namespace ts { * @see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances */ function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { - const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; - const className = getNameOfSymbol(getSymbolOfNode(node)); for (const member of node.members) { - const isStatic = getModifierFlags(member) & ModifierFlags.Static; - const isMethod = member.kind === SyntaxKind.MethodDeclaration; const memberNameNode = member.name; + const isStatic = getModifierFlags(member) & ModifierFlags.Static; if (isStatic && memberNameNode) { const memberName = getPropertyNameForPropertyNameNode(memberNameNode); - if (languageVersion <= ScriptTarget.ES5) { // ES3, ES5 - if (memberName === "prototype" || - memberName === "name" || - memberName === "length" || - memberName === "caller" || - memberName === "arguments" - ) { + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + const className = getNameOfSymbol(getSymbolOfNode(node)); error(memberNameNode, message, memberName, className); - } - } - else { // ES6+ - if (memberName === "prototype") { - error(memberNameNode, message, memberName, className); - } - else if (( - memberName === "name" || - memberName === "length" || - memberName === "caller" || - memberName === "arguments") && - isMethod === false - ) { - error(memberNameNode, message, memberName, className); - } + break; } } } diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt deleted file mode 100644 index 004365d3e76..00000000000 --- a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt +++ /dev/null @@ -1,92 +0,0 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(4,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(9,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(15,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(20,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(26,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2300: Duplicate identifier 'prototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(37,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(42,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(48,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(53,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. - - -==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts (11 errors) ==== - - // static name - class StaticName { - static name: number; // error - ~~~~ -!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. - name: string; // ok - } - - class StaticNameFn { - static name() {} // error - ~~~~ -!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. - name() {} // ok - } - - - class StaticLength { - static length: number; // error - ~~~~~~ -!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. - length: string; // ok - } - - class StaticLengthFn { - static length() {} // error - ~~~~~~ -!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. - length() {} // ok - } - - - class StaticPrototype { - static prototype: number; // error - ~~~~~~~~~ -!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. - prototype: string; // ok - } - - class StaticPrototypeFn { - static prototype() {} // error - ~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'prototype'. - ~~~~~~~~~ -!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. - prototype() {} // ok - } - - - class StaticCaller { - static caller: number; // error - ~~~~~~ -!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. - caller: string; // ok - } - - class StaticCallerFn { - static caller() {} // error - ~~~~~~ -!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. - caller() {} // ok - } - - - class StaticArguments { - static arguments: number; // error - ~~~~~~~~~ -!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. - arguments: string; // ok - } - - class StaticArgumentsFn { - static arguments() {} // error - ~~~~~~~~~ -!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. - arguments() {} // ok - } - \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs5.js b/tests/baselines/reference/staticPropertyNameConflictsEs5.js deleted file mode 100644 index 06d4a011a8e..00000000000 --- a/tests/baselines/reference/staticPropertyNameConflictsEs5.js +++ /dev/null @@ -1,120 +0,0 @@ -//// [staticPropertyNameConflictsEs5.ts] - -// static name -class StaticName { - static name: number; // error - name: string; // ok -} - -class StaticNameFn { - static name() {} // error - name() {} // ok -} - - -class StaticLength { - static length: number; // error - length: string; // ok -} - -class StaticLengthFn { - static length() {} // error - length() {} // ok -} - - -class StaticPrototype { - static prototype: number; // error - prototype: string; // ok -} - -class StaticPrototypeFn { - static prototype() {} // error - prototype() {} // ok -} - - -class StaticCaller { - static caller: number; // error - caller: string; // ok -} - -class StaticCallerFn { - static caller() {} // error - caller() {} // ok -} - - -class StaticArguments { - static arguments: number; // error - arguments: string; // ok -} - -class StaticArgumentsFn { - static arguments() {} // error - arguments() {} // ok -} - - -//// [staticPropertyNameConflictsEs5.js] -// static name -var StaticName = (function () { - function StaticName() { - } - return StaticName; -}()); -var StaticNameFn = (function () { - function StaticNameFn() { - } - StaticNameFn.name = function () { }; // error - StaticNameFn.prototype.name = function () { }; // ok - return StaticNameFn; -}()); -var StaticLength = (function () { - function StaticLength() { - } - return StaticLength; -}()); -var StaticLengthFn = (function () { - function StaticLengthFn() { - } - StaticLengthFn.length = function () { }; // error - StaticLengthFn.prototype.length = function () { }; // ok - return StaticLengthFn; -}()); -var StaticPrototype = (function () { - function StaticPrototype() { - } - return StaticPrototype; -}()); -var StaticPrototypeFn = (function () { - function StaticPrototypeFn() { - } - StaticPrototypeFn.prototype = function () { }; // error - StaticPrototypeFn.prototype.prototype = function () { }; // ok - return StaticPrototypeFn; -}()); -var StaticCaller = (function () { - function StaticCaller() { - } - return StaticCaller; -}()); -var StaticCallerFn = (function () { - function StaticCallerFn() { - } - StaticCallerFn.caller = function () { }; // error - StaticCallerFn.prototype.caller = function () { }; // ok - return StaticCallerFn; -}()); -var StaticArguments = (function () { - function StaticArguments() { - } - return StaticArguments; -}()); -var StaticArgumentsFn = (function () { - function StaticArgumentsFn() { - } - StaticArgumentsFn.arguments = function () { }; // error - StaticArgumentsFn.prototype.arguments = function () { }; // ok - return StaticArgumentsFn; -}()); diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt deleted file mode 100644 index 607735bb12f..00000000000 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt +++ /dev/null @@ -1,80 +0,0 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(4,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(15,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2300: Duplicate identifier 'prototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. - - -==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (7 errors) ==== - - - class StaticName { - static name: number; // error - ~~~~ -!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. - name: string; // ok - } - - class StaticNameFn { - static name() {} // ok - name() {} // ok - } - - - class StaticLength { - static length: number; // error - ~~~~~~ -!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. - length: string; // ok - } - - class StaticLengthFn { - static length() {} // ok - length() {} // ok - } - - - class StaticPrototype { - static prototype: number; // error - ~~~~~~~~~ -!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. - prototype: string; // ok - } - - class StaticPrototypeFn { - static prototype() {} // error - ~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'prototype'. - ~~~~~~~~~ -!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. - prototype() {} // ok - } - - - class StaticCaller { - static caller: number; // error - ~~~~~~ -!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. - caller: string; // ok - } - - class StaticCallerFn { - static caller() {} // ok - caller() {} // ok - } - - - class StaticArguments { - static arguments: number; // error - ~~~~~~~~~ -!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. - arguments: string; // ok - } - - class StaticArgumentsFn { - static arguments() {} // ok - arguments() {} // ok - } - \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.js b/tests/baselines/reference/staticPropertyNameConflictsEs6.js deleted file mode 100644 index 7adef10b141..00000000000 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.js +++ /dev/null @@ -1,89 +0,0 @@ -//// [staticPropertyNameConflictsEs6.ts] - - -class StaticName { - static name: number; // error - name: string; // ok -} - -class StaticNameFn { - static name() {} // ok - name() {} // ok -} - - -class StaticLength { - static length: number; // error - length: string; // ok -} - -class StaticLengthFn { - static length() {} // ok - length() {} // ok -} - - -class StaticPrototype { - static prototype: number; // error - prototype: string; // ok -} - -class StaticPrototypeFn { - static prototype() {} // error - prototype() {} // ok -} - - -class StaticCaller { - static caller: number; // error - caller: string; // ok -} - -class StaticCallerFn { - static caller() {} // ok - caller() {} // ok -} - - -class StaticArguments { - static arguments: number; // error - arguments: string; // ok -} - -class StaticArgumentsFn { - static arguments() {} // ok - arguments() {} // ok -} - - -//// [staticPropertyNameConflictsEs6.js] -class StaticName { -} -class StaticNameFn { - static name() { } // ok - name() { } // ok -} -class StaticLength { -} -class StaticLengthFn { - static length() { } // ok - length() { } // ok -} -class StaticPrototype { -} -class StaticPrototypeFn { - static prototype() { } // error - prototype() { } // ok -} -class StaticCaller { -} -class StaticCallerFn { - static caller() { } // ok - caller() { } // ok -} -class StaticArguments { -} -class StaticArgumentsFn { - static arguments() { } // ok - arguments() { } // ok -} diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts index 5eb09ddb2d3..86755cb016d 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts @@ -1,6 +1,5 @@ -// @target: es5 - -// static name +// @target: es5 +// name class StaticName { static name: number; // error name: string; // ok @@ -11,7 +10,7 @@ class StaticNameFn { name() {} // ok } - +// length class StaticLength { static length: number; // error length: string; // ok @@ -22,7 +21,7 @@ class StaticLengthFn { length() {} // ok } - +// prototype class StaticPrototype { static prototype: number; // error prototype: string; // ok @@ -33,7 +32,7 @@ class StaticPrototypeFn { prototype() {} // ok } - +// caller class StaticCaller { static caller: number; // error caller: string; // ok @@ -44,7 +43,7 @@ class StaticCallerFn { caller() {} // ok } - +// arguments class StaticArguments { static arguments: number; // error arguments: string; // ok @@ -54,3 +53,140 @@ class StaticArgumentsFn { static arguments() {} // error arguments() {} // ok } + + + +// === Static properties on anonymous classes === + +// name +var StaticName_Anonymous = class { + static name: number; // error + name: string; // ok +} + +var StaticNameFn_Anonymous = class { + static name() {} // error + name() {} // ok +} + +// length +var StaticLength_Anonymous = class { + static length: number; // error + length: string; // ok +} + +var StaticLengthFn_Anonymous = class { + static length() {} // error + length() {} // ok +} + +// prototype +var StaticPrototype_Anonymous = class { + static prototype: number; // error + prototype: string; // ok +} + +var StaticPrototypeFn_Anonymous = class { + static prototype() {} // error + prototype() {} // ok +} + +// caller +var StaticCaller_Anonymous = class { + static caller: number; // error + caller: string; // ok +} + +var StaticCallerFn_Anonymous = class { + static caller() {} // error + caller() {} // ok +} + +// arguments +var StaticArguments_Anonymous = class { + static arguments: number; // error + arguments: string; // ok +} + +var StaticArgumentsFn_Anonymous = class { + static arguments() {} // error + arguments() {} // ok +} + + +// === Static properties on default exported classes === + +// name +module TestOnDefaultExportedClass_1 { + class StaticName { + static name: number; // error + name: string; // ok + } +} + +module TestOnDefaultExportedClass_2 { + class StaticNameFn { + static name() {} // error + name() {} // ok + } +} + +// length +module TestOnDefaultExportedClass_3 { + export default class StaticLength { + static length: number; // error + length: string; // ok + } +} + +module TestOnDefaultExportedClass_4 { + export default class StaticLengthFn { + static length() {} // error + length() {} // ok + } +} + +// prototype +module TestOnDefaultExportedClass_5 { + export default class StaticPrototype { + static prototype: number; // error + prototype: string; // ok + } +} + +module TestOnDefaultExportedClass_6 { + export default class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok + } +} + +// caller +module TestOnDefaultExportedClass_7 { + export default class StaticCaller { + static caller: number; // error + caller: string; // ok + } +} + +module TestOnDefaultExportedClass_8 { + export default class StaticCallerFn { + static caller() {} // error + caller() {} // ok + } +} + +// arguments +module TestOnDefaultExportedClass_9 { + export default class StaticArguments { + static arguments: number; // error + arguments: string; // ok + } +} + +module TestOnDefaultExportedClass_10 { + export default class StaticArgumentsFn { + static arguments() {} // error + arguments() {} // ok + } +} \ No newline at end of file From 061175ef9fb6ab985de56b9c4b49db4bdd4d272a Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sun, 15 Jan 2017 16:26:17 -0800 Subject: [PATCH 124/175] Emit 'object' type in declaration emitter --- src/compiler/declarationEmitter.ts | 1 + .../reference/nonPrimitiveAsProperty.js | 8 ++++++++ .../reference/nonPrimitiveInFunction.js | 8 ++++++++ .../reference/nonPrimitiveInGeneric.js | 18 ++++++++++++++++++ .../reference/nonPrimitiveUnionIntersection.js | 5 +++++ .../nonPrimitive/nonPrimitiveAsProperty.ts | 1 + .../nonPrimitive/nonPrimitiveInFunction.ts | 1 + .../nonPrimitive/nonPrimitiveInGeneric.ts | 1 + .../nonPrimitiveUnionIntersection.ts | 1 + 9 files changed, 44 insertions(+) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index cd98622e080..bdeb700f1d1 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -390,6 +390,7 @@ namespace ts { case SyntaxKind.StringKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: diff --git a/tests/baselines/reference/nonPrimitiveAsProperty.js b/tests/baselines/reference/nonPrimitiveAsProperty.js index f51a9b35435..d3e1b072a06 100644 --- a/tests/baselines/reference/nonPrimitiveAsProperty.js +++ b/tests/baselines/reference/nonPrimitiveAsProperty.js @@ -11,3 +11,11 @@ var b: WithNonPrimitive = {foo: "bar"}; // expect error //// [nonPrimitiveAsProperty.js] var a = { foo: { bar: "bar" } }; var b = { foo: "bar" }; // expect error + + +//// [nonPrimitiveAsProperty.d.ts] +interface WithNonPrimitive { + foo: object; +} +declare var a: WithNonPrimitive; +declare var b: WithNonPrimitive; diff --git a/tests/baselines/reference/nonPrimitiveInFunction.js b/tests/baselines/reference/nonPrimitiveInFunction.js index a67b68542dd..1d2a2462502 100644 --- a/tests/baselines/reference/nonPrimitiveInFunction.js +++ b/tests/baselines/reference/nonPrimitiveInFunction.js @@ -34,3 +34,11 @@ function returnError() { var ret = 123; return ret; // expect error } + + +//// [nonPrimitiveInFunction.d.ts] +declare function takeObject(o: object): void; +declare function returnObject(): object; +declare var nonPrimitive: object; +declare var primitive: boolean; +declare function returnError(): object; diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.js b/tests/baselines/reference/nonPrimitiveInGeneric.js index 2db357c3eb5..d7e013c71f1 100644 --- a/tests/baselines/reference/nonPrimitiveInGeneric.js +++ b/tests/baselines/reference/nonPrimitiveInGeneric.js @@ -73,3 +73,21 @@ var x; // error var y; // ok var z; // ok var u; // ok + + +//// [nonPrimitiveInGeneric.d.ts] +declare function generic(t: T): void; +declare var a: {}; +declare var b: string; +declare function bound(t: T): void; +declare function bound2(): void; +declare function bound3(t: T): void; +interface Proxy { +} +declare var x: Proxy; +declare var y: Proxy; +declare var z: Proxy; +interface Blah { + foo: number; +} +declare var u: Proxy; diff --git a/tests/baselines/reference/nonPrimitiveUnionIntersection.js b/tests/baselines/reference/nonPrimitiveUnionIntersection.js index c50a2330018..7f4b46c42ed 100644 --- a/tests/baselines/reference/nonPrimitiveUnionIntersection.js +++ b/tests/baselines/reference/nonPrimitiveUnionIntersection.js @@ -10,3 +10,8 @@ var a = ""; // error var b = ""; // ok a = b; // error b = a; // ok + + +//// [nonPrimitiveUnionIntersection.d.ts] +declare var a: object & string; +declare var b: object | string; diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts index ee4011ecf7d..3cd2ce4cef5 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts @@ -1,3 +1,4 @@ +// @declaration: true interface WithNonPrimitive { foo: object } diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts index c38693dbfb1..d56c02fafe9 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts @@ -1,3 +1,4 @@ +// @declaration: true function takeObject(o: object) {} function returnObject(): object { return {}; diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts index 836896b5a57..490a9f88135 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts @@ -1,3 +1,4 @@ +// @declaration: true function generic(t: T) { var o: object = t; // expect error } diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts index c1667c7a32e..a9d5872705c 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts @@ -1,3 +1,4 @@ +// @declaration: true var a: object & string = ""; // error var b: object | string = ""; // ok a = b; // error From 919e682e3f53ee8dbc914c27d04763406e29becb Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 16 Jan 2017 12:18:01 -0800 Subject: [PATCH 125/175] Allow T[N] where N is numeric and T has apparent numeric index signature --- src/compiler/checker.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 80516ef9319..9ea61bc2655 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16032,14 +16032,24 @@ namespace ts { } function checkIndexedAccessIndexType(type: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode) { - if (type.flags & TypeFlags.IndexedAccess) { - // Check that the index type is assignable to 'keyof T' for the object type. - const objectType = (type).objectType; - const indexType = (type).indexType; - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + if (!(type.flags & TypeFlags.IndexedAccess)) { + return type; + } + // Check if the index type is assignable to 'keyof T' for the object type. + const objectType = (type).objectType; + const indexType = (type).indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + // 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); + if (constraint && getIndexInfoOfType(constraint, IndexKind.Number)) { + return type; } } + error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); return type; } From f7d8e3befccd86c348d69083fdf823c49169ee06 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 16 Jan 2017 12:18:15 -0800 Subject: [PATCH 126/175] Add regression test --- tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts index 27e47da177c..a4088e65df4 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts @@ -501,3 +501,7 @@ function updateIds2( var x = obj[key]; stringMap[x]; // Should be OK. } + +// Repro from #13514 + +declare function head>(list: T): T[0]; From 59a8aa4d828fde5a69b0e76f788ec1366bcc2f6e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 16 Jan 2017 14:30:24 -0800 Subject: [PATCH 127/175] Accept new baselines --- tests/baselines/reference/keyofAndIndexedAccess.js | 5 +++++ .../baselines/reference/keyofAndIndexedAccess.symbols | 10 ++++++++++ tests/baselines/reference/keyofAndIndexedAccess.types | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.js b/tests/baselines/reference/keyofAndIndexedAccess.js index 05658d50515..a86184c8ff0 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.js +++ b/tests/baselines/reference/keyofAndIndexedAccess.js @@ -500,6 +500,10 @@ function updateIds2( var x = obj[key]; stringMap[x]; // Should be OK. } + +// Repro from #13514 + +declare function head>(list: T): T[0]; //// [keyofAndIndexedAccess.js] @@ -1061,3 +1065,4 @@ declare function updateIds2(obj: T, key: K, stringMap: { [oldId: string]: string; }): void; +declare function head>(list: T): T[0]; diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index d7bc419af24..4c12c6554c9 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -1806,3 +1806,13 @@ function updateIds2( >x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 498, 7)) } +// Repro from #13514 + +declare function head>(list: T): T[0]; +>head : Symbol(head, Decl(keyofAndIndexedAccess.ts, 500, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 504, 22)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>list : Symbol(list, Decl(keyofAndIndexedAccess.ts, 504, 44)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 504, 22)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 504, 22)) + diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 543c39b3c92..3919d768151 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -2128,3 +2128,13 @@ function updateIds2( >x : T[K] } +// Repro from #13514 + +declare function head>(list: T): T[0]; +>head : (list: T) => T[0] +>T : T +>Array : T[] +>list : T +>T : T +>T : T + From f1e7142f3c7e74224a15780651f86330fbadfd90 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 17 Jan 2017 07:42:31 -0800 Subject: [PATCH 128/175] Move code out of closure in `getCompletionsAtPosition` --- src/services/completions.ts | 1145 ++++++++++++++++++----------------- 1 file changed, 573 insertions(+), 572 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index 8c0d52b2c34..acb78772132 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,12 +1,14 @@ /* @internal */ namespace ts.Completions { - export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo | undefined { + 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); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } const completionData = getCompletionData(typeChecker, log, sourceFile, position); @@ -24,8 +26,8 @@ namespace ts.Completions { const entries: CompletionEntry[] = []; if (isSourceFileJavaScript(sourceFile)) { - const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); - addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { @@ -48,7 +50,7 @@ namespace ts.Completions { } } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list @@ -57,693 +59,692 @@ namespace ts.Completions { } return { isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries }; + } - function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map): CompletionEntry[] { - const entries: CompletionEntry[] = []; + function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map, target: ScriptTarget): CompletionEntry[] { + const entries: CompletionEntry[] = []; - const nameTable = getNameTable(sourceFile); - for (const name in nameTable) { - // Skip identifiers produced only from the current location - if (nameTable[name] === position) { - continue; + const nameTable = getNameTable(sourceFile); + for (const name in nameTable) { + // Skip identifiers produced only from the current location + if (nameTable[name] === position) { + continue; + } + + if (!uniqueNames[name]) { + uniqueNames[name] = name; + const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), target, /*performCharacterChecks*/ true); + if (displayName) { + const entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } + } + } - if (!uniqueNames[name]) { - uniqueNames[name] = name; - const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), compilerOptions.target, /*performCharacterChecks*/ true); - if (displayName) { - const entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + return entries; + } + + function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget): CompletionEntry { + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // We would like to only show things that can be added after a dot, so for instance numeric properties can + // not be accessed with a dot (a.1 <- invalid) + const displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location); + if (!displayName) { + return undefined; + } + + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // really we should consider passing the meaning for the node so that we don't report + // that a suggestion for a value is an interface. We COULD also just do what + // 'getSymbolModifiers' does, which is to use the first declaration. + + // Use a 'sortText' of 0' so that all symbol completion entries come before any other + // entries (like JavaScript identifier entries). + return { + name: displayName, + kind: SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + + function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: Push, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, log: Log): Map { + const start = timestamp(); + const uniqueNames = createMap(); + if (symbols) { + for (const symbol of symbols) { + const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + const id = escapeIdentifier(entry.name); + if (!uniqueNames[id]) { entries.push(entry); + uniqueNames[id] = id; } } } - - return entries; } - function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean): CompletionEntry { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. - // We would like to only show things that can be added after a dot, so for instance numeric properties can - // not be accessed with a dot (a.1 <- invalid) - const displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; - } - - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but - // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what - // 'getSymbolModifiers' does, which is to use the first declaration. - - // Use a 'sortText' of 0' so that all symbol completion entries come before any other - // entries (like JavaScript identifier entries). - return { - name: displayName, - kind: SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number, typeChecker: TypeChecker, compilerOptions: CompilerOptions, host: LanguageServiceHost, log: Log): CompletionInfo | undefined { + const node = findPrecedingToken(position, sourceFile); + if (!node || node.kind !== SyntaxKind.StringLiteral) { + return undefined; } - function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[], location: Node, performCharacterChecks: boolean): Map { - const start = timestamp(); - const uniqueNames = createMap(); - if (symbols) { - for (const symbol of symbols) { - const entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - const id = escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; - } - } - } - } - - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start)); - return uniqueNames; + if (node.parent.kind === SyntaxKind.PropertyAssignment && + node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression && + (node.parent).name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); } - - function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number): CompletionInfo | undefined { - const node = findPrecedingToken(position, sourceFile); - if (!node || node.kind !== SyntaxKind.StringLiteral) { - return undefined; - } - - if (node.parent.kind === SyntaxKind.PropertyAssignment && - node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression && - (node.parent).name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); - } - else if (isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - // i.e. import * as ns from "/*completion position*/"; - // import x = require("/*completion position*/"); - // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node); - } - else { - const argumentInfo = SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - // Get string literal completions from specialized signatures of the target - // i.e. declare function f(a: 'A'); - // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - - // Get completion for string literal from string literal type - // i.e. var x: "hi" | "hello" = "/*completion position*/" - return getStringLiteralCompletionEntriesFromContextualType(node); - } + else if (isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); } - - function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement): CompletionInfo | undefined { - const type = typeChecker.getContextualType((element.parent)); - const entries: CompletionEntry[] = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; - } - } + else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); } - - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo): CompletionInfo | undefined { - const candidates: Signature[] = []; - const entries: CompletionEntry[] = []; - - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - - for (const candidate of candidates) { - addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries); + else { + const argumentInfo = SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + // Get string literal completions from specialized signatures of the target + // i.e. declare function f(a: 'A'); + // f("/*completion position*/") + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } + // Get completion for string literal from string literal type + // i.e. var x: "hi" | "hello" = "/*completion position*/" + return getStringLiteralCompletionEntriesFromContextualType(node, typeChecker); + } + } + + function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement, typeChecker: TypeChecker, target: ScriptTarget, log: Log): CompletionInfo | undefined { + const type = typeChecker.getContextualType((element.parent)); + const entries: CompletionEntry[] = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/false, typeChecker, target, log); if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; } + } + } - return undefined; + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, typeChecker: TypeChecker): CompletionInfo | undefined { + const candidates: Signature[] = []; + const entries: CompletionEntry[] = []; + + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + + for (const candidate of candidates) { + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); } - function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression): CompletionInfo | undefined { - const type = typeChecker.getTypeAtLocation(node.expression); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries }; + } + + return undefined; + } + + function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression, typeChecker: TypeChecker, target: ScriptTarget, log: Log): CompletionInfo | undefined { + const type = typeChecker.getTypeAtLocation(node.expression); + const entries: CompletionEntry[] = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + } + } + return undefined; + } + + function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral, typeChecker: TypeChecker): CompletionInfo | undefined { + const type = typeChecker.getContextualType(node); + if (type) { const entries: CompletionEntry[] = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; - } - } - return undefined; - } - - function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral): CompletionInfo | undefined { - const type = typeChecker.getContextualType(node); - if (type) { - const entries: CompletionEntry[] = []; - addStringLiteralCompletionsFromType(type, entries); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries }; - } - } - return undefined; - } - - function addStringLiteralCompletionsFromType(type: Type, result: Push): void { - if (type && type.flags & TypeFlags.TypeParameter) { - type = typeChecker.getApparentType(type); - } - if (!type) { - return; - } - if (type.flags & TypeFlags.Union) { - for (const t of (type).types) { - addStringLiteralCompletionsFromType(t, result); - } - } - else if (type.flags & TypeFlags.StringLiteral) { - result.push({ - name: (type).text, - kindModifiers: ScriptElementKindModifier.none, - kind: ScriptElementKind.variableElement, - sortText: "0" - }); + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries }; } } + return undefined; + } - function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral): CompletionInfo { - const literalValue = normalizeSlashes(node.text); + function addStringLiteralCompletionsFromType(type: Type, result: Push, typeChecker: TypeChecker): void { + if (type && type.flags & TypeFlags.TypeParameter) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & TypeFlags.Union) { + for (const t of (type).types) { + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & TypeFlags.StringLiteral) { + result.push({ + name: (type).text, + kindModifiers: ScriptElementKindModifier.none, + kind: ScriptElementKind.variableElement, + sortText: "0" + }); + } + } - const scriptPath = node.getSourceFile().path; - const scriptDirectory = getDirectoryPath(scriptPath); + function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionInfo { + const literalValue = normalizeSlashes(node.text); - const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); - let entries: CompletionEntry[]; - if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( - compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment( - literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath); - } + 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 { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); + entries = getCompletionEntriesForDirectoryFragment( + literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, host, scriptPath); } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries - }; } + 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); /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. */ - 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))); + fragment = getDirectoryPath(fragment); - // 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))); + if (fragment === "") { + fragment = "." + directorySeparator; } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string): CompletionEntry[] { - const basePath = compilerOptions.project || host.getCurrentDirectory(); - const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + fragment = ensureTrailingDirectorySeparator(fragment); - const result: CompletionEntry[] = []; + const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); + const baseDirectory = getDirectoryPath(absolutePath); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - for (const baseDirectory of baseDirectories) { - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); - 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, 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[foundFileName]) { - foundFiles[foundFileName] = true; - } + 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; } - for (const foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); + const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); + + if (!foundFiles[foundFileName]) { + foundFiles[foundFileName] = true; } } - // 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)); - } + for (const foundFile in foundFiles) { + result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); } } - return result; + // 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)); + } + } } - /** - * 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): CompletionEntry[] { - const { baseUrl, paths } = compilerOptions; + return result; + } - let result: CompletionEntry[]; + /** + * 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; - 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); + let result: CompletionEntry[]; - 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)) { - result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); - } + 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 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)) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); - } - - return result; + } + else { + result = []; } - function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[]): 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); + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; + for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host)) { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + } - // 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; + return result; + } - const normalizedSuffix = normalizePath(parsed.suffix); - const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); - const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + 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); - // 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 fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; - const matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - const result: string[] = []; + // 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; - // Trim away prefix and suffix - for (const match of matches) { - const normalizedMatch = normalizePath(match); - if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { - continue; - } + const normalizedSuffix = normalizePath(parsed.suffix); + const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); + const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - const start = completePrefix.length; - const length = normalizedMatch.length - start - normalizedSuffix.length; + // 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 ? "**/*" : "./*"; - result.push(removeFileExtension(normalizedMatch.substr(start, length))); + 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 result; } } } + } + 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; } - function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions): string[] { - // Check If this is a nested module - const isNestedModule = fragment.indexOf(directorySeparator) !== -1; - const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; + const range = forEach(commentRanges, commentRange => position >= commentRange.pos && position <= commentRange.end && commentRange); - // 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); + if (!range) { + return undefined; } - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number): CompletionInfo { - const token = getTokenAtPosition(sourceFile, position); - if (!token) { - 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); } - const commentRanges: CommentRange[] = getLeadingCommentRanges(sourceFile.text, token.pos); - - if (!commentRanges || !commentRanges.length) { - return undefined; + 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); } - - 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, 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) {} + return completionInfo; + } - if (typeRoots) { - for (const root of typeRoots) { - getCompletionEntriesFromDirectories(host, root, span, result); - } - } + 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)); } - - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (const packageJson of findPackageJsons(scriptPath)) { - const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - - return result; } + else if (host.getDirectories) { + let typeRoots: string[]; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = getEffectiveTypeRoots(options, host); + } + catch (e) {} - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: CompletionEntry[]) { - 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)); - } + if (typeRoots) { + for (const root of typeRoots) { + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function findPackageJsons(currentDir: string): string[] { - const paths: string[] = []; - let currentConfigPath: string; - while (true) { - currentConfigPath = findConfigFile(currentDir, (f) => tryFileExists(host, f), "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); + 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); + } + } - currentDir = getDirectoryPath(currentConfigPath); - const parent = getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; + 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)); } - else { + } + } + } + + 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; } + return paths; + } - function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { - const result: VisibleModuleInfo[] = []; + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { + const result: VisibleModuleInfo[] = []; - if (host.readFile && host.fileExists) { - for (const packageJson of findPackageJsons(scriptPath)) { - 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 - }); - } + if (host.readFile && host.fileExists) { + for (const packageJson of findPackageJsons(scriptPath, host)) { + const contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; } - } - return result; + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; - function tryReadingPackageJson(filePath: string) { - try { - const fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; + // Provide completions for all non @types dependencies + for (const key of nodeModulesDependencyKeys) { + addPotentialPackageNames(contents[key], foundModuleNames); } - 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); - } - } + for (const moduleName of foundModuleNames) { + const moduleDir = combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName, + moduleDir + }); } } } - function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { - return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; - } + return result; - // 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; + function tryReadingPackageJson(filePath: string) { + try { + const fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; + } + catch (e) { + return undefined; } - return false; } - function normalizeAndPreserveTrailingSlash(path: string) { - return hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalizePath(path)) : normalizePath(path); + 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); From 9fbadfdc67809636a580cd939ea7f815b8214a91 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 17 Jan 2017 08:02:39 -0800 Subject: [PATCH 129/175] Move `"types": []` to tsconfig-base --- src/compiler/tsconfig.json | 3 +-- src/services/tsconfig.json | 3 +-- src/tsconfig-base.json | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index 1ed009444b1..52bb92ee1f0 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -3,8 +3,7 @@ "compilerOptions": { "removeComments": true, "outFile": "../../built/local/tsc.js", - "declaration": true, - "types": [ ] + "declaration": true }, "files": [ "core.ts", diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 13686d232a1..b60e00292f5 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -3,8 +3,7 @@ "compilerOptions": { "removeComments": false, "outFile": "../../built/local/typescriptServices.js", - "declaration": true, - "types": [] + "declaration": true }, "files": [ "../compiler/core.ts", diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index b4c82dbeeee..2eb1851dc5c 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -9,6 +9,7 @@ "preserveConstEnums": true, "stripInternal": true, "sourceMap": true, - "target": "es5" + "target": "es5", + "types": [] } } \ No newline at end of file From d1fb894d8661664648a73882f3aca998794ad805 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 17 Jan 2017 10:29:54 -0800 Subject: [PATCH 130/175] Update document highlight tests: Use ranges to represent expected highlights --- src/harness/fourslash.ts | 83 ++++++++++++------- ...documentHighlightAtInheritedProperties1.ts | 10 +-- ...documentHighlightAtInheritedProperties2.ts | 10 +-- ...documentHighlightAtInheritedProperties3.ts | 14 ++-- ...documentHighlightAtInheritedProperties4.ts | 14 ++-- ...documentHighlightAtInheritedProperties5.ts | 29 ++----- ...documentHighlightAtInheritedProperties6.ts | 33 +++----- ...ighlightAtParameterPropertyDeclaration1.ts | 30 +++---- ...ighlightAtParameterPropertyDeclaration2.ts | 31 ++++--- ...ighlightAtParameterPropertyDeclaration3.ts | 31 ++++--- tests/cases/fourslash/fourslash.ts | 4 +- ...PropertySymbolsFromBaseTypesDoesntCrash.ts | 5 +- .../fourslash/server/documentHighlights01.ts | 12 +-- .../fourslash/server/documentHighlights02.ts | 22 +---- 14 files changed, 135 insertions(+), 193 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8ad715681ec..1afb6de2cf2 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -859,9 +859,8 @@ namespace FourSlash { } } - public verifyReferencesOf({fileName, start}: Range, references: Range[]) { - this.openFile(fileName); - this.goToPosition(start); + public verifyReferencesOf(range: Range, references: Range[]) { + this.goToRangeStart(range); this.verifyReferencesAre(references); } @@ -1669,6 +1668,11 @@ namespace FourSlash { this.goToPosition(len); } + private goToRangeStart({fileName, start}: Range) { + this.openFile(fileName); + this.goToPosition(start); + } + public goToTypeDefinition(definitionIndex: number) { const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { @@ -2361,40 +2365,45 @@ namespace FourSlash { return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch); } - public verifyDocumentHighlightsAtPositionListContains(fileName: string, start: number, end: number, fileNamesToSearch: string[], kind?: string) { - const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); + public verifyRangesWithSameTextAreDocumentHighlights() { + this.rangesByText().forEach(ranges => this.verifyRangesAreDocumentHighlights(ranges)); + } - if (!documentHighlights || documentHighlights.length === 0) { - this.raiseError("verifyDocumentHighlightsAtPositionListContains failed - found 0 highlights, expected at least one."); + public verifyRangesAreDocumentHighlights(ranges?: Range[]) { + ranges = ranges || this.getRanges(); + const fileNames = unique(ranges, range => range.fileName); + for (const range of ranges) { + this.goToRangeStart(range); + this.verifyDocumentHighlights(ranges, fileNames); } + } - for (const documentHighlight of documentHighlights) { - if (documentHighlight.fileName === fileName) { - const { highlightSpans } = documentHighlight; + private verifyDocumentHighlights(expectedRanges: Range[], fileNames: string[] = [this.activeFile.fileName]) { + const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNames) || []; - for (const highlight of highlightSpans) { - if (highlight && highlight.textSpan.start === start && ts.textSpanEnd(highlight.textSpan) === end) { - if (typeof kind !== "undefined" && highlight.kind !== kind) { - this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - item "kind" value does not match, actual: ${highlight.kind}, expected: ${kind}.`); - } - return; - } - } + for (const dh of documentHighlights) { + if (fileNames.indexOf(dh.fileName) === -1) { + this.raiseError(`verifyDocumentHighlights failed - got highlights in unexpected file name ${dh.fileName}`); } } - const missingItem = { fileName: fileName, start: start, end: end, kind: kind }; - this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(documentHighlights)})`); - } + for (const fileName of fileNames) { + const expectedRangesInFile = expectedRanges.filter(r => r.fileName === fileName); + const highlights = ts.find(documentHighlights, dh => dh.fileName === fileName); + if (!highlights) { + this.raiseError(`verifyDocumentHighlights failed - found no highlights in ${fileName}`); + } + const spansInFile = highlights.highlightSpans.sort((s1, s2) => s1.textSpan.start - s2.textSpan.start); - public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) { - const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); - const actualCount = documentHighlights - ? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0) - : 0; + if (expectedRangesInFile.length !== spansInFile.length) { + this.raiseError(`verifyDocumentHighlights failed - In ${fileName}, expected ${expectedRangesInFile.length} highlights, got ${spansInFile.length}`); + } - if (expectedCount !== actualCount) { - this.raiseError("verifyDocumentHighlightsAtPositionListCount failed - actual: " + actualCount + ", expected:" + expectedCount); + ts.zipWith(expectedRangesInFile, spansInFile, (expectedRange, span) => { + if (span.textSpan.start !== expectedRange.start || ts.textSpanEnd(span.textSpan) !== expectedRange.end) { + this.raiseError(`verifyDocumentHighlights failed - span does not match, actual: ${JSON.stringify(span.textSpan)}, expected: ${expectedRange.start}--${expectedRange.end}`); + } + }); } } @@ -3021,6 +3030,16 @@ ${code} function stringify(data: any, replacer?: (key: string, value: any) => any): string { return JSON.stringify(data, replacer, 2); } + + /** Collects an array of unique outputs. */ + function unique(inputs: T[], getOutput: (t: T) => string): string[] { + const set = ts.createMap(); + for (const input of inputs) { + const out = getOutput(input); + set.set(out, true); + } + return ts.arrayFrom(set.keys()); + } } namespace FourSlashInterface { @@ -3413,12 +3432,12 @@ namespace FourSlashInterface { this.state.verifyOccurrencesAtPositionListCount(expectedCount); } - public documentHighlightsAtPositionContains(range: FourSlash.Range, fileNamesToSearch: string[], kind?: string) { - this.state.verifyDocumentHighlightsAtPositionListContains(range.fileName, range.start, range.end, fileNamesToSearch, kind); + public rangesAreDocumentHighlights(ranges?: FourSlash.Range[]) { + this.state.verifyRangesAreDocumentHighlights(ranges); } - public documentHighlightsAtPositionCount(expectedCount: number, fileNamesToSearch: string[]) { - this.state.verifyDocumentHighlightsAtPositionListCount(expectedCount, fileNamesToSearch); + public rangesWithSameTextAreDocumentHighlights() { + this.state.verifyRangesWithSameTextAreDocumentHighlights(); } public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string) { diff --git a/tests/cases/fourslash/documentHighlightAtInheritedProperties1.ts b/tests/cases/fourslash/documentHighlightAtInheritedProperties1.ts index 23f6445a004..0c07edea506 100644 --- a/tests/cases/fourslash/documentHighlightAtInheritedProperties1.ts +++ b/tests/cases/fourslash/documentHighlightAtInheritedProperties1.ts @@ -2,12 +2,8 @@ // @Filename: file1.ts //// interface interface1 extends interface1 { -//// /*1*/doStuff(): void; -//// /*2*/propName: string; +//// [|doStuff|](): void; +//// [|propName|]: string; //// } -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - verify.documentHighlightsAtPositionCount(1, ["file1.ts"]); -} +verify.rangesWithSameTextAreDocumentHighlights(); diff --git a/tests/cases/fourslash/documentHighlightAtInheritedProperties2.ts b/tests/cases/fourslash/documentHighlightAtInheritedProperties2.ts index d4aadf96ed6..3327c36b760 100644 --- a/tests/cases/fourslash/documentHighlightAtInheritedProperties2.ts +++ b/tests/cases/fourslash/documentHighlightAtInheritedProperties2.ts @@ -2,12 +2,8 @@ // @Filename: file1.ts //// class class1 extends class1 { -//// /*1*/doStuff() { } -//// /*2*/propName: string; +//// [|doStuff|]() { } +//// [|propName|]: string; //// } -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - verify.documentHighlightsAtPositionCount(1, ["file1.ts"]); -} \ No newline at end of file +verify.rangesWithSameTextAreDocumentHighlights(); diff --git a/tests/cases/fourslash/documentHighlightAtInheritedProperties3.ts b/tests/cases/fourslash/documentHighlightAtInheritedProperties3.ts index 5e94bb387cd..11625df1442 100644 --- a/tests/cases/fourslash/documentHighlightAtInheritedProperties3.ts +++ b/tests/cases/fourslash/documentHighlightAtInheritedProperties3.ts @@ -2,16 +2,12 @@ // @Filename: file1.ts //// interface interface1 extends interface1 { -//// /*1*/doStuff(): void; -//// /*2*/propName: string; +//// [|doStuff|](): void; +//// [|propName|]: string; //// } //// //// var v: interface1; -//// v./*3*/propName; -//// v./*4*/doStuff(); +//// v.[|propName|]; +//// v.[|doStuff|](); -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - verify.documentHighlightsAtPositionCount(2, ["file1.ts"]); -} +verify.rangesWithSameTextAreDocumentHighlights(); diff --git a/tests/cases/fourslash/documentHighlightAtInheritedProperties4.ts b/tests/cases/fourslash/documentHighlightAtInheritedProperties4.ts index 50f459ebfdb..1c78233554a 100644 --- a/tests/cases/fourslash/documentHighlightAtInheritedProperties4.ts +++ b/tests/cases/fourslash/documentHighlightAtInheritedProperties4.ts @@ -2,16 +2,12 @@ // @Filename: file1.ts //// class class1 extends class1 { -//// /*1*/doStuff() { } -//// /*2*/propName: string; +//// [|doStuff|]() { } +//// [|propName|]: string; //// } //// //// var c: class1; -//// c./*3*/doStuff(); -//// c./*4*/propName; +//// c.[|doStuff|](); +//// c.[|propName|]; -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - verify.documentHighlightsAtPositionCount(2, ["file1.ts"]); -} +verify.rangesWithSameTextAreDocumentHighlights(); diff --git a/tests/cases/fourslash/documentHighlightAtInheritedProperties5.ts b/tests/cases/fourslash/documentHighlightAtInheritedProperties5.ts index b5f4cbb00a7..4fdf4a689ac 100644 --- a/tests/cases/fourslash/documentHighlightAtInheritedProperties5.ts +++ b/tests/cases/fourslash/documentHighlightAtInheritedProperties5.ts @@ -2,29 +2,16 @@ // @Filename: file1.ts //// interface C extends D { -//// /*0*/prop0: string; -//// /*1*/prop1: number; +//// [|prop0|]: string; +//// [|prop1|]: number; //// } -//// +//// //// interface D extends C { -//// /*2*/prop0: string; -//// /*3*/prop1: number; +//// [|prop0|]: string; +//// [|prop1|]: number; //// } -//// +//// //// var d: D; -//// d./*4*/prop1; +//// d.[|prop1|]; -goTo.marker("0"); -verify.documentHighlightsAtPositionCount(2, ["file1.ts"]); - -goTo.marker("1"); -verify.documentHighlightsAtPositionCount(3, ["file1.ts"]); - -goTo.marker("2"); -verify.documentHighlightsAtPositionCount(2, ["file1.ts"]); - -goTo.marker("3"); -verify.documentHighlightsAtPositionCount(3, ["file1.ts"]); - -goTo.marker("4"); -verify.documentHighlightsAtPositionCount(3, ["file1.ts"]); \ No newline at end of file +verify.rangesWithSameTextAreDocumentHighlights(); diff --git a/tests/cases/fourslash/documentHighlightAtInheritedProperties6.ts b/tests/cases/fourslash/documentHighlightAtInheritedProperties6.ts index 8f1089e567d..6eb7ae16723 100644 --- a/tests/cases/fourslash/documentHighlightAtInheritedProperties6.ts +++ b/tests/cases/fourslash/documentHighlightAtInheritedProperties6.ts @@ -2,29 +2,20 @@ // @Filename: file1.ts //// class C extends D { -//// /*0*/prop0: string; -//// /*1*/prop1: string; +//// [|prop0|]: string; +//// [|prop1|]: string; //// } -//// +//// //// class D extends C { -//// /*2*/prop0: string; -//// /*3*/prop1: string; +//// [|prop0|]: string; +//// [|prop1|]: string; //// } -//// +//// //// var d: D; -//// d./*4*/prop1; +//// d.[|prop1|]; -goTo.marker("0"); -verify.documentHighlightsAtPositionCount(1, ["file1.ts"]); - -goTo.marker("1"); -verify.documentHighlightsAtPositionCount(1, ["file1.ts"]); - -goTo.marker("2"); -verify.documentHighlightsAtPositionCount(1, ["file1.ts"]); - -goTo.marker("3"); -verify.documentHighlightsAtPositionCount(2, ["file1.ts"]); - -goTo.marker("4"); -verify.documentHighlightsAtPositionCount(2, ["file1.ts"]); \ No newline at end of file +const [Cprop0, Cprop1, Dprop0, Dprop1, prop1Use] = test.ranges(); +verify.rangesAreDocumentHighlights([Cprop0]); +verify.rangesAreDocumentHighlights([Dprop0]); +verify.rangesAreDocumentHighlights([Cprop1]); +verify.rangesAreDocumentHighlights([Dprop1, prop1Use]); diff --git a/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration1.ts b/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration1.ts index aeccd252fe9..219ea427b9c 100644 --- a/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration1.ts +++ b/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration1.ts @@ -2,23 +2,19 @@ // @Filename: file1.ts //// class Foo { -//// constructor(private /*0*/privateParam: number, -//// public /*1*/publicParam: string, -//// protected /*2*/protectedParam: boolean) { -//// -//// let localPrivate = /*3*/privateParam; -//// this./*4*/privateParam += 10; -//// -//// let localPublic = /*5*/publicParam; -//// this./*6*/publicParam += " Hello!"; -//// -//// let localProtected = /*7*/protectedParam; -//// this./*8*/protectedParam = false; +//// constructor(private [|privateParam|]: number, +//// public [|publicParam|]: string, +//// protected [|protectedParam|]: boolean) { +//// +//// let localPrivate = [|privateParam|]; +//// this.[|privateParam|] += 10; +//// +//// let localPublic = [|publicParam|]; +//// this.[|publicParam|] += " Hello!"; +//// +//// let localProtected = [|protectedParam|]; +//// this.[|protectedParam|] = false; //// } //// } -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - verify.documentHighlightsAtPositionCount(3, ["file1.ts"]); -} \ No newline at end of file +verify.rangesWithSameTextAreDocumentHighlights(); diff --git a/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration2.ts b/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration2.ts index f5d6764205b..199f59fc8a3 100644 --- a/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration2.ts +++ b/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration2.ts @@ -2,23 +2,20 @@ // @Filename: file1.ts //// class Foo { -//// constructor(private {/*0*/privateParam}: number, -//// public {/*1*/publicParam}: string, -//// protected {/*2*/protectedParam}: boolean) { -//// -//// let localPrivate = /*3*/privateParam; -//// this.privateParam += 10; // this is not valid syntax -//// -//// let localPublic = /*4*/publicParam; -//// this.publicParam += " Hello!"; // this is not valid syntax -//// -//// let localProtected = /*5*/protectedParam; -//// this.protectedParam = false; // this is not valid syntax +//// // This is not valid syntax: parameter property can't be binding pattern +//// constructor(private {[|privateParam|]}: number, +//// public {[|publicParam|]}: string, +//// protected {[|protectedParam|]}: boolean) { +//// +//// let localPrivate = [|privateParam|]; +//// this.privateParam += 10; +//// +//// let localPublic = [|publicParam|]; +//// this.publicParam += " Hello!"; +//// +//// let localProtected = [|protectedParam|]; +//// this.protectedParam = false; //// } //// } -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - verify.documentHighlightsAtPositionCount(2, ["file1.ts"]); -} \ No newline at end of file +verify.rangesWithSameTextAreDocumentHighlights(); diff --git a/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration3.ts b/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration3.ts index 958e3bb45c9..7bcd44a5425 100644 --- a/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration3.ts +++ b/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration3.ts @@ -2,23 +2,20 @@ // @Filename: file1.ts //// class Foo { -//// constructor(private [/*0*/privateParam]: number, -//// public [/*1*/publicParam]: string, -//// protected [/*2*/protectedParam]: boolean) { -//// -//// let localPrivate = /*3*/privateParam; -//// this.privateParam += 10; // this is not valid syntax -//// -//// let localPublic = /*4*/publicParam; -//// this.publicParam += " Hello!"; // this is not valid syntax -//// -//// let localProtected = /*5*/protectedParam; -//// this.protectedParam = false; // this is not valid syntax +//// // This is not valid syntax: parameter property can't be binding pattern +//// constructor(private [[|privateParam|]]: number, +//// public [[|publicParam|]]: string, +//// protected [[|protectedParam|]]: boolean) { +//// +//// let localPrivate = [|privateParam|]; +//// this.privateParam += 10; +//// +//// let localPublic = [|publicParam|]; +//// this.publicParam += " Hello!"; +//// +//// let localProtected = [|protectedParam|]; +//// this.protectedParam = false; //// } //// } -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - verify.documentHighlightsAtPositionCount(2, ["file1.ts"]); -} \ No newline at end of file +verify.rangesWithSameTextAreDocumentHighlights(); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index ab67abc1bb6..ed09fcd2c92 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -229,8 +229,8 @@ declare namespace FourSlashInterface { navigationItemsListContains(name: string, kind: string, searchValue: string, matchKind: string, fileName?: string, parentName?: string): void; occurrencesAtPositionContains(range: Range, isWriteAccess?: boolean): void; occurrencesAtPositionCount(expectedCount: number): void; - documentHighlightsAtPositionContains(range: Range, fileNamesToSearch: string[], kind?: string): void; - documentHighlightsAtPositionCount(expectedCount: number, fileNamesToSearch: string[]): void; + rangesAreDocumentHighlights(ranges?: Range[]): void; + rangesWithSameTextAreDocumentHighlights(): void; completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string): void; /** * This method *requires* a contiguous, complete, and ordered stream of classifications for a file. diff --git a/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts b/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts index 0c89de63a43..e141a257f2e 100644 --- a/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts +++ b/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts @@ -2,8 +2,7 @@ // @Filename: file1.ts //// class ClassA implements IInterface { -//// private /*1*/value: number; +//// private [|value|]: number; //// } -goTo.marker("1"); -verify.documentHighlightsAtPositionCount(1, ["file1.ts"]); \ No newline at end of file +verify.rangesAreDocumentHighlights(); diff --git a/tests/cases/fourslash/server/documentHighlights01.ts b/tests/cases/fourslash/server/documentHighlights01.ts index d4be88f9357..0acfbcb9d11 100644 --- a/tests/cases/fourslash/server/documentHighlights01.ts +++ b/tests/cases/fourslash/server/documentHighlights01.ts @@ -5,14 +5,4 @@ //// [|f|]([|f|]); ////} -let ranges = test.ranges(); - -for (let r of ranges) { - goTo.position(r.start); - verify.documentHighlightsAtPositionCount(ranges.length, ["a.ts"]); - - for (let range of ranges) { - verify.documentHighlightsAtPositionContains(range, ["a.ts"]); - } -} - +verify.rangesAreDocumentHighlights(); diff --git a/tests/cases/fourslash/server/documentHighlights02.ts b/tests/cases/fourslash/server/documentHighlights02.ts index 357f82e9c2d..3fd71d4a65d 100644 --- a/tests/cases/fourslash/server/documentHighlights02.ts +++ b/tests/cases/fourslash/server/documentHighlights02.ts @@ -8,28 +8,10 @@ // @Filename: b.ts /////// -////foo(); +////[|foo|](); // open two files goTo.file("a.ts"); goTo.file("b.ts"); -let ranges = test.ranges(); - -for (let i = 0; i < ranges.length; ++i) { - let r = ranges[i]; - - if (i < 2) { - goTo.file("a.ts"); - } - else { - goTo.file("b.ts"); - } - - goTo.position(r.start); - verify.documentHighlightsAtPositionCount(3, ["a.ts", "b.ts"]); - - for (let range of ranges) { - verify.documentHighlightsAtPositionContains(range, ["a.ts", "b.ts"]); - } -} +verify.rangesAreDocumentHighlights(); From 9ebdd30ce41b30d1e8ef841e8a84a2d92df19ac1 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 17 Jan 2017 14:36:55 -0800 Subject: [PATCH 131/175] Remove added newline --- src/harness/harness.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 840ebaa1662..1dd41f9d81c 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -55,7 +55,6 @@ interface XMLHttpRequest { } /* tslint:enable:no-var-keyword */ - namespace Utils { // Setup some globals based on the current environment export const enum ExecutionEnvironment { From bddcbc5f20dec6b3148f61fd1bc1223c1bda870d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 17 Jan 2017 14:30:40 -0800 Subject: [PATCH 132/175] Move code out of closure in `getDocumentHighlights`, then again out of `getSemanticDocumentHighlights` and `getSyntacticDocumentHighlights`. Also return a `Node[]` instead of a `HighlightSpan[]` where possible and do mapping from Node to HighlightSpan in one place. --- src/services/documentHighlights.ts | 1192 ++++++++++++++-------------- 1 file changed, 593 insertions(+), 599 deletions(-) diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 212e145ca60..79fa0236bc5 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -2,626 +2,620 @@ namespace ts.DocumentHighlights { export function getDocumentHighlights(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] { const node = getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + + function getHighlightSpanForNode(node: Node, sourceFile: SourceFile): HighlightSpan { + const start = node.getStart(sourceFile); + const end = node.getEnd(); + + return { + fileName: sourceFile.fileName, + textSpan: createTextSpanFromBounds(start, end), + kind: HighlightSpanKind.none + }; + } + + function getSemanticDocumentHighlights(node: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] { + if (node.kind === SyntaxKind.Identifier || + node.kind === SyntaxKind.ThisKeyword || + node.kind === SyntaxKind.ThisType || + node.kind === SyntaxKind.SuperKeyword || + node.kind === SyntaxKind.StringLiteral || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/false); + return convertReferencedSymbols(referencedSymbols); + } + + return undefined; + } + + function convertReferencedSymbols(referencedSymbols: ReferencedSymbol[]): DocumentHighlights[] { + if (!referencedSymbols) { + return undefined; + } + + const fileNameToDocumentHighlights = createMap(); + const result: DocumentHighlights[] = []; + for (const referencedSymbol of referencedSymbols) { + for (const referenceEntry of referencedSymbol.references) { + const fileName = referenceEntry.fileName; + let documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName, highlightSpans: [] }; + + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + }); + } + } + + return result; + } + + function getSyntacticDocumentHighlights(node: Node, sourceFile: SourceFile): DocumentHighlights[] { + const highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + + return [{ fileName: sourceFile.fileName, highlightSpans }]; + } + + // returns true if 'node' is defined and has a matching 'kind'. + function hasKind(node: Node, kind: SyntaxKind) { + return node !== undefined && node.kind === kind; + } + + // Null-propagating 'parent' function. + function parent(node: Node): Node { + return node && node.parent; + } + + function getHighlightSpans(node: Node, sourceFile: SourceFile): HighlightSpan[] { if (!node) { return undefined; } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - - function getHighlightSpanForNode(node: Node): HighlightSpan { - const start = node.getStart(); - const end = node.getEnd(); - - return { - fileName: sourceFile.fileName, - textSpan: createTextSpanFromBounds(start, end), - kind: HighlightSpanKind.none - }; + switch (node.kind) { + case SyntaxKind.IfKeyword: + case SyntaxKind.ElseKeyword: + if (hasKind(node.parent, SyntaxKind.IfStatement)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case SyntaxKind.ReturnKeyword: + if (hasKind(node.parent, SyntaxKind.ReturnStatement)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case SyntaxKind.ThrowKeyword: + if (hasKind(node.parent, SyntaxKind.ThrowStatement)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case SyntaxKind.TryKeyword: + case SyntaxKind.CatchKeyword: + case SyntaxKind.FinallyKeyword: + const tryStatement = node.kind === SyntaxKind.CatchKeyword ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, SyntaxKind.TryStatement)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case SyntaxKind.SwitchKeyword: + if (hasKind(node.parent, SyntaxKind.SwitchStatement)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case SyntaxKind.CaseKeyword: + case SyntaxKind.DefaultKeyword: + if (hasKind(parent(parent(parent(node))), SyntaxKind.SwitchStatement)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case SyntaxKind.BreakKeyword: + case SyntaxKind.ContinueKeyword: + if (hasKind(node.parent, SyntaxKind.BreakStatement) || hasKind(node.parent, SyntaxKind.ContinueStatement)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case SyntaxKind.ForKeyword: + if (hasKind(node.parent, SyntaxKind.ForStatement) || + hasKind(node.parent, SyntaxKind.ForInStatement) || + hasKind(node.parent, SyntaxKind.ForOfStatement)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case SyntaxKind.WhileKeyword: + case SyntaxKind.DoKeyword: + if (hasKind(node.parent, SyntaxKind.WhileStatement) || hasKind(node.parent, SyntaxKind.DoStatement)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case SyntaxKind.ConstructorKeyword: + if (hasKind(node.parent, SyntaxKind.Constructor)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case SyntaxKind.GetKeyword: + case SyntaxKind.SetKeyword: + if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (isModifierKind(node.kind) && node.parent && + (isDeclaration(node.parent) || node.parent.kind === SyntaxKind.VariableStatement)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node: Node): DocumentHighlights[] { - if (node.kind === SyntaxKind.Identifier || - node.kind === SyntaxKind.ThisKeyword || - node.kind === SyntaxKind.ThisType || - node.kind === SyntaxKind.SuperKeyword || - node.kind === SyntaxKind.StringLiteral || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/false); - return convertReferencedSymbols(referencedSymbols); - - } - - return undefined; - - function convertReferencedSymbols(referencedSymbols: ReferencedSymbol[]): DocumentHighlights[] { - if (!referencedSymbols) { - return undefined; - } - - const fileNameToDocumentHighlights = createMap(); - const result: DocumentHighlights[] = []; - for (const referencedSymbol of referencedSymbols) { - for (const referenceEntry of referencedSymbol.references) { - const fileName = referenceEntry.fileName; - let documentHighlights = fileNameToDocumentHighlights.get(fileName); - if (!documentHighlights) { - documentHighlights = { fileName, highlightSpans: [] }; - - fileNameToDocumentHighlights.set(fileName, documentHighlights); - result.push(documentHighlights); - } - - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference - }); - } - } - - return result; - } + function highlightSpans(nodes: Node[]): HighlightSpan[] { + return nodes && nodes.map(node => getHighlightSpanForNode(node, sourceFile)); } + } - function getSyntacticDocumentHighlights(node: Node): DocumentHighlights[] { - const fileName = sourceFile.fileName; + /** + * Aggregates all throw-statements within this node *without* crossing + * into function boundaries and try-blocks with catch-clauses. + */ + function aggregateOwnedThrowStatements(node: Node): ThrowStatement[] { + const statementAccumulator: ThrowStatement[] = []; + aggregate(node); + return statementAccumulator; - const highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; + function aggregate(node: Node): void { + if (node.kind === SyntaxKind.ThrowStatement) { + statementAccumulator.push(node); } - - return [{ fileName, highlightSpans }]; - - // returns true if 'node' is defined and has a matching 'kind'. - function hasKind(node: Node, kind: SyntaxKind) { - return node !== undefined && node.kind === kind; - } - - // Null-propagating 'parent' function. - function parent(node: Node): Node { - return node && node.parent; - } - - function getHighlightSpans(node: Node): HighlightSpan[] { - if (node) { - switch (node.kind) { - case SyntaxKind.IfKeyword: - case SyntaxKind.ElseKeyword: - if (hasKind(node.parent, SyntaxKind.IfStatement)) { - return getIfElseOccurrences(node.parent); - } - break; - case SyntaxKind.ReturnKeyword: - if (hasKind(node.parent, SyntaxKind.ReturnStatement)) { - return getReturnOccurrences(node.parent); - } - break; - case SyntaxKind.ThrowKeyword: - if (hasKind(node.parent, SyntaxKind.ThrowStatement)) { - return getThrowOccurrences(node.parent); - } - break; - case SyntaxKind.CatchKeyword: - if (hasKind(parent(parent(node)), SyntaxKind.TryStatement)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case SyntaxKind.TryKeyword: - case SyntaxKind.FinallyKeyword: - if (hasKind(parent(node), SyntaxKind.TryStatement)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case SyntaxKind.SwitchKeyword: - if (hasKind(node.parent, SyntaxKind.SwitchStatement)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case SyntaxKind.CaseKeyword: - case SyntaxKind.DefaultKeyword: - if (hasKind(parent(parent(parent(node))), SyntaxKind.SwitchStatement)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case SyntaxKind.BreakKeyword: - case SyntaxKind.ContinueKeyword: - if (hasKind(node.parent, SyntaxKind.BreakStatement) || hasKind(node.parent, SyntaxKind.ContinueStatement)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case SyntaxKind.ForKeyword: - if (hasKind(node.parent, SyntaxKind.ForStatement) || - hasKind(node.parent, SyntaxKind.ForInStatement) || - hasKind(node.parent, SyntaxKind.ForOfStatement)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case SyntaxKind.WhileKeyword: - case SyntaxKind.DoKeyword: - if (hasKind(node.parent, SyntaxKind.WhileStatement) || hasKind(node.parent, SyntaxKind.DoStatement)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case SyntaxKind.ConstructorKeyword: - if (hasKind(node.parent, SyntaxKind.Constructor)) { - return getConstructorOccurrences(node.parent); - } - break; - case SyntaxKind.GetKeyword: - case SyntaxKind.SetKeyword: - if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (isModifierKind(node.kind) && node.parent && - (isDeclaration(node.parent) || node.parent.kind === SyntaxKind.VariableStatement)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - - return undefined; - } - - /** - * Aggregates all throw-statements within this node *without* crossing - * into function boundaries and try-blocks with catch-clauses. - */ - function aggregateOwnedThrowStatements(node: Node): ThrowStatement[] { - const statementAccumulator: ThrowStatement[] = []; - aggregate(node); - return statementAccumulator; - - function aggregate(node: Node): void { - if (node.kind === SyntaxKind.ThrowStatement) { - statementAccumulator.push(node); - } - else if (node.kind === SyntaxKind.TryStatement) { - const tryStatement = node; - - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); - } - else { - // Exceptions thrown within a try block lacking a catch clause - // are "owned" in the current context. - aggregate(tryStatement.tryBlock); - } - - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); - } - } - // Do not cross function boundaries. - else if (!isFunctionLike(node)) { - forEachChild(node, aggregate); - } - } - } - - /** - * For lack of a better name, this function takes a throw statement and returns the - * nearest ancestor that is a try-block (whose try statement has a catch clause), - * function-block, or source file. - */ - function getThrowStatementOwner(throwStatement: ThrowStatement): Node { - let child: Node = throwStatement; - - while (child.parent) { - const parent = child.parent; - - if (isFunctionBlock(parent) || parent.kind === SyntaxKind.SourceFile) { - return parent; - } - - // A throw-statement is only owned by a try-statement if the try-statement has - // a catch clause, and if the throw-statement occurs within the try block. - if (parent.kind === SyntaxKind.TryStatement) { - const tryStatement = parent; - - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - - child = parent; - } - - return undefined; - } - - function aggregateAllBreakAndContinueStatements(node: Node): BreakOrContinueStatement[] { - const statementAccumulator: BreakOrContinueStatement[] = []; - aggregate(node); - return statementAccumulator; - - function aggregate(node: Node): void { - if (node.kind === SyntaxKind.BreakStatement || node.kind === SyntaxKind.ContinueStatement) { - statementAccumulator.push(node); - } - // Do not cross function boundaries. - else if (!isFunctionLike(node)) { - forEachChild(node, aggregate); - } - } - } - - function ownsBreakOrContinueStatement(owner: Node, statement: BreakOrContinueStatement): boolean { - const actualOwner = getBreakOrContinueOwner(statement); - - return actualOwner && actualOwner === owner; - } - - function getBreakOrContinueOwner(statement: BreakOrContinueStatement): Node { - for (let node = statement.parent; node; node = node.parent) { - switch (node.kind) { - case SyntaxKind.SwitchStatement: - if (statement.kind === SyntaxKind.ContinueStatement) { - continue; - } - // Fall through. - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.DoStatement: - if (!statement.label || isLabeledBy(node, statement.label.text)) { - return node; - } - break; - default: - // Don't cross function boundaries. - if (isFunctionLike(node)) { - return undefined; - } - break; - } - } - - return undefined; - } - - function getModifierOccurrences(modifier: SyntaxKind, declaration: Node): HighlightSpan[] { - const container = declaration.parent; - - // Make sure we only highlight the keyword when it makes sense to do so. - if (isAccessibilityModifier(modifier)) { - if (!(container.kind === SyntaxKind.ClassDeclaration || - container.kind === SyntaxKind.ClassExpression || - (declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) { - return undefined; - } - } - else if (modifier === SyntaxKind.StaticKeyword) { - if (!(container.kind === SyntaxKind.ClassDeclaration || container.kind === SyntaxKind.ClassExpression)) { - return undefined; - } - } - else if (modifier === SyntaxKind.ExportKeyword || modifier === SyntaxKind.DeclareKeyword) { - if (!(container.kind === SyntaxKind.ModuleBlock || container.kind === SyntaxKind.SourceFile)) { - return undefined; - } - } - else if (modifier === SyntaxKind.AbstractKeyword) { - if (!(container.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.ClassDeclaration)) { - return undefined; - } - } - else { - // unsupported modifier - return undefined; - } - - const keywords: Node[] = []; - const modifierFlag: ModifierFlags = getFlagFromModifier(modifier); - - let nodes: Node[]; - switch (container.kind) { - case SyntaxKind.ModuleBlock: - case SyntaxKind.SourceFile: - // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & ModifierFlags.Abstract) { - nodes = ((declaration).members).concat(declaration); - } - else { - nodes = (container).statements; - } - break; - case SyntaxKind.Constructor: - nodes = ((container).parameters).concat( - (container.parent).members); - break; - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - nodes = (container).members; - - // If we're an accessibility modifier, we're in an instance member and should search - // the constructor's parameter list for instance members as well. - if (modifierFlag & ModifierFlags.AccessibilityModifier) { - const constructor = forEach((container).members, member => { - return member.kind === SyntaxKind.Constructor && member; - }); - - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & ModifierFlags.Abstract) { - nodes = nodes.concat(container); - } - break; - default: - Debug.fail("Invalid container kind."); - } - - forEach(nodes, node => { - if (getModifierFlags(node) & modifierFlag) { - forEach(node.modifiers, child => pushKeywordIf(keywords, child, modifier)); - } - }); - - return map(keywords, getHighlightSpanForNode); - - function getFlagFromModifier(modifier: SyntaxKind) { - switch (modifier) { - case SyntaxKind.PublicKeyword: - return ModifierFlags.Public; - case SyntaxKind.PrivateKeyword: - return ModifierFlags.Private; - case SyntaxKind.ProtectedKeyword: - return ModifierFlags.Protected; - case SyntaxKind.StaticKeyword: - return ModifierFlags.Static; - case SyntaxKind.ExportKeyword: - return ModifierFlags.Export; - case SyntaxKind.DeclareKeyword: - return ModifierFlags.Ambient; - case SyntaxKind.AbstractKeyword: - return ModifierFlags.Abstract; - default: - Debug.fail(); - } - } - } - - function pushKeywordIf(keywordList: Node[], token: Node, ...expected: SyntaxKind[]): boolean { - if (token && contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - - return false; - } - - function getGetAndSetOccurrences(accessorDeclaration: AccessorDeclaration): HighlightSpan[] { - const keywords: Node[] = []; - - tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.GetAccessor); - tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.SetAccessor); - - return map(keywords, getHighlightSpanForNode); - - function tryPushAccessorKeyword(accessorSymbol: Symbol, accessorKind: SyntaxKind): void { - const accessor = getDeclarationOfKind(accessorSymbol, accessorKind); - - if (accessor) { - forEach(accessor.getChildren(), child => pushKeywordIf(keywords, child, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword)); - } - } - } - - function getConstructorOccurrences(constructorDeclaration: ConstructorDeclaration): HighlightSpan[] { - const declarations = constructorDeclaration.symbol.getDeclarations(); - - const keywords: Node[] = []; - - forEach(declarations, declaration => { - forEach(declaration.getChildren(), token => { - return pushKeywordIf(keywords, token, SyntaxKind.ConstructorKeyword); - }); - }); - - return map(keywords, getHighlightSpanForNode); - } - - function getLoopBreakContinueOccurrences(loopNode: IterationStatement): HighlightSpan[] { - const keywords: Node[] = []; - - if (pushKeywordIf(keywords, loopNode.getFirstToken(), SyntaxKind.ForKeyword, SyntaxKind.WhileKeyword, SyntaxKind.DoKeyword)) { - // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === SyntaxKind.DoStatement) { - const loopTokens = loopNode.getChildren(); - - for (let i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], SyntaxKind.WhileKeyword)) { - break; - } - } - } - } - - const breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - - forEach(breaksAndContinues, statement => { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), SyntaxKind.BreakKeyword, SyntaxKind.ContinueKeyword); - } - }); - - return map(keywords, getHighlightSpanForNode); - } - - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement: BreakOrContinueStatement): HighlightSpan[] { - const owner = getBreakOrContinueOwner(breakOrContinueStatement); - - if (owner) { - switch (owner.kind) { - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - return getLoopBreakContinueOccurrences(owner); - case SyntaxKind.SwitchStatement: - return getSwitchCaseDefaultOccurrences(owner); - - } - } - - return undefined; - } - - function getSwitchCaseDefaultOccurrences(switchStatement: SwitchStatement): HighlightSpan[] { - const keywords: Node[] = []; - - pushKeywordIf(keywords, switchStatement.getFirstToken(), SyntaxKind.SwitchKeyword); - - // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. - forEach(switchStatement.caseBlock.clauses, clause => { - pushKeywordIf(keywords, clause.getFirstToken(), SyntaxKind.CaseKeyword, SyntaxKind.DefaultKeyword); - - const breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - - forEach(breaksAndContinues, statement => { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), SyntaxKind.BreakKeyword); - } - }); - }); - - return map(keywords, getHighlightSpanForNode); - } - - function getTryCatchFinallyOccurrences(tryStatement: TryStatement): HighlightSpan[] { - const keywords: Node[] = []; - - pushKeywordIf(keywords, tryStatement.getFirstToken(), SyntaxKind.TryKeyword); + else if (node.kind === SyntaxKind.TryStatement) { + const tryStatement = node; if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), SyntaxKind.CatchKeyword); + aggregate(tryStatement.catchClause); + } + else { + // Exceptions thrown within a try block lacking a catch clause + // are "owned" in the current context. + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - const finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile); - pushKeywordIf(keywords, finallyKeyword, SyntaxKind.FinallyKeyword); + aggregate(tryStatement.finallyBlock); } - - return map(keywords, getHighlightSpanForNode); } - - function getThrowOccurrences(throwStatement: ThrowStatement): HighlightSpan[] { - const owner = getThrowStatementOwner(throwStatement); - - if (!owner) { - return undefined; - } - - const keywords: Node[] = []; - - forEach(aggregateOwnedThrowStatements(owner), throwStatement => { - pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.ThrowKeyword); - }); - - // If the "owner" is a function, then we equate 'return' and 'throw' statements in their - // ability to "jump out" of the function, and include occurrences for both. - if (isFunctionBlock(owner)) { - forEachReturnStatement(owner, returnStatement => { - pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword); - }); - } - - return map(keywords, getHighlightSpanForNode); - } - - function getReturnOccurrences(returnStatement: ReturnStatement): HighlightSpan[] { - const func = getContainingFunction(returnStatement); - - // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, SyntaxKind.Block))) { - return undefined; - } - - const keywords: Node[] = []; - forEachReturnStatement(func.body, returnStatement => { - pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword); - }); - - // Include 'throw' statements that do not occur within a try block. - forEach(aggregateOwnedThrowStatements(func.body), throwStatement => { - pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.ThrowKeyword); - }); - - return map(keywords, getHighlightSpanForNode); - } - - function getIfElseOccurrences(ifStatement: IfStatement): HighlightSpan[] { - const keywords: Node[] = []; - - // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, SyntaxKind.IfStatement) && (ifStatement.parent).elseStatement === ifStatement) { - ifStatement = ifStatement.parent; - } - - // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. - while (ifStatement) { - const children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], SyntaxKind.IfKeyword); - - // Generally the 'else' keyword is second-to-last, so we traverse backwards. - for (let i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], SyntaxKind.ElseKeyword)) { - break; - } - } - - if (!hasKind(ifStatement.elseStatement, SyntaxKind.IfStatement)) { - break; - } - - ifStatement = ifStatement.elseStatement; - } - - const result: HighlightSpan[] = []; - - // We'd like to highlight else/ifs together if they are only separated by whitespace - // (i.e. the keywords are separated by no comments, no newlines). - for (let i = 0; i < keywords.length; i++) { - if (keywords[i].kind === SyntaxKind.ElseKeyword && i < keywords.length - 1) { - const elseKeyword = keywords[i]; - const ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. - - let shouldCombindElseAndIf = true; - - // Avoid recalculating getStart() by iterating backwards. - for (let j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: HighlightSpanKind.reference - }); - i++; // skip the next keyword - continue; - } - } - - // Ordinary case: just highlight the keyword. - result.push(getHighlightSpanForNode(keywords[i])); - } - - return result; + // Do not cross function boundaries. + else if (!isFunctionLike(node)) { + forEachChild(node, aggregate); } } } + /** + * For lack of a better name, this function takes a throw statement and returns the + * nearest ancestor that is a try-block (whose try statement has a catch clause), + * function-block, or source file. + */ + function getThrowStatementOwner(throwStatement: ThrowStatement): Node { + let child: Node = throwStatement; + + while (child.parent) { + const parent = child.parent; + + if (isFunctionBlock(parent) || parent.kind === SyntaxKind.SourceFile) { + return parent; + } + + // A throw-statement is only owned by a try-statement if the try-statement has + // a catch clause, and if the throw-statement occurs within the try block. + if (parent.kind === SyntaxKind.TryStatement) { + const tryStatement = parent; + + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + + child = parent; + } + + return undefined; + } + + function aggregateAllBreakAndContinueStatements(node: Node): BreakOrContinueStatement[] { + const statementAccumulator: BreakOrContinueStatement[] = []; + aggregate(node); + return statementAccumulator; + + function aggregate(node: Node): void { + if (node.kind === SyntaxKind.BreakStatement || node.kind === SyntaxKind.ContinueStatement) { + statementAccumulator.push(node); + } + // Do not cross function boundaries. + else if (!isFunctionLike(node)) { + forEachChild(node, aggregate); + } + } + } + + function ownsBreakOrContinueStatement(owner: Node, statement: BreakOrContinueStatement): boolean { + const actualOwner = getBreakOrContinueOwner(statement); + + return actualOwner && actualOwner === owner; + } + + function getBreakOrContinueOwner(statement: BreakOrContinueStatement): Node { + for (let node = statement.parent; node; node = node.parent) { + switch (node.kind) { + case SyntaxKind.SwitchStatement: + if (statement.kind === SyntaxKind.ContinueStatement) { + continue; + } + // Fall through. + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.DoStatement: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + // Don't cross function boundaries. + if (isFunctionLike(node)) { + return undefined; + } + break; + } + } + + return undefined; + } + + function getModifierOccurrences(modifier: SyntaxKind, declaration: Node): Node[] { + const container = declaration.parent; + + // Make sure we only highlight the keyword when it makes sense to do so. + if (isAccessibilityModifier(modifier)) { + if (!(container.kind === SyntaxKind.ClassDeclaration || + container.kind === SyntaxKind.ClassExpression || + (declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) { + return undefined; + } + } + else if (modifier === SyntaxKind.StaticKeyword) { + if (!(container.kind === SyntaxKind.ClassDeclaration || container.kind === SyntaxKind.ClassExpression)) { + return undefined; + } + } + else if (modifier === SyntaxKind.ExportKeyword || modifier === SyntaxKind.DeclareKeyword) { + if (!(container.kind === SyntaxKind.ModuleBlock || container.kind === SyntaxKind.SourceFile)) { + return undefined; + } + } + else if (modifier === SyntaxKind.AbstractKeyword) { + if (!(container.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.ClassDeclaration)) { + return undefined; + } + } + else { + // unsupported modifier + return undefined; + } + + const keywords: Node[] = []; + const modifierFlag: ModifierFlags = getFlagFromModifier(modifier); + + let nodes: Node[]; + switch (container.kind) { + case SyntaxKind.ModuleBlock: + case SyntaxKind.SourceFile: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & ModifierFlags.Abstract) { + nodes = ((declaration).members).concat(declaration); + } + else { + nodes = (container).statements; + } + break; + case SyntaxKind.Constructor: + nodes = ((container).parameters).concat( + (container.parent).members); + break; + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + nodes = (container).members; + + // If we're an accessibility modifier, we're in an instance member and should search + // the constructor's parameter list for instance members as well. + if (modifierFlag & ModifierFlags.AccessibilityModifier) { + const constructor = forEach((container).members, member => { + return member.kind === SyntaxKind.Constructor && member; + }); + + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & ModifierFlags.Abstract) { + nodes = nodes.concat(container); + } + break; + default: + Debug.fail("Invalid container kind."); + } + + forEach(nodes, node => { + if (getModifierFlags(node) & modifierFlag) { + forEach(node.modifiers, child => pushKeywordIf(keywords, child, modifier)); + } + }); + + return keywords; + + function getFlagFromModifier(modifier: SyntaxKind) { + switch (modifier) { + case SyntaxKind.PublicKeyword: + return ModifierFlags.Public; + case SyntaxKind.PrivateKeyword: + return ModifierFlags.Private; + case SyntaxKind.ProtectedKeyword: + return ModifierFlags.Protected; + case SyntaxKind.StaticKeyword: + return ModifierFlags.Static; + case SyntaxKind.ExportKeyword: + return ModifierFlags.Export; + case SyntaxKind.DeclareKeyword: + return ModifierFlags.Ambient; + case SyntaxKind.AbstractKeyword: + return ModifierFlags.Abstract; + default: + Debug.fail(); + } + } + } + + function pushKeywordIf(keywordList: Node[], token: Node, ...expected: SyntaxKind[]): boolean { + if (token && contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + + return false; + } + + function getGetAndSetOccurrences(accessorDeclaration: AccessorDeclaration): Node[] { + const keywords: Node[] = []; + + tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.GetAccessor); + tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.SetAccessor); + + return keywords; + + function tryPushAccessorKeyword(accessorSymbol: Symbol, accessorKind: SyntaxKind): void { + const accessor = getDeclarationOfKind(accessorSymbol, accessorKind); + + if (accessor) { + forEach(accessor.getChildren(), child => pushKeywordIf(keywords, child, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword)); + } + } + } + + function getConstructorOccurrences(constructorDeclaration: ConstructorDeclaration): Node[] { + const declarations = constructorDeclaration.symbol.getDeclarations(); + + const keywords: Node[] = []; + + forEach(declarations, declaration => { + forEach(declaration.getChildren(), token => { + return pushKeywordIf(keywords, token, SyntaxKind.ConstructorKeyword); + }); + }); + + return keywords; + } + + function getLoopBreakContinueOccurrences(loopNode: IterationStatement): Node[] { + const keywords: Node[] = []; + + if (pushKeywordIf(keywords, loopNode.getFirstToken(), SyntaxKind.ForKeyword, SyntaxKind.WhileKeyword, SyntaxKind.DoKeyword)) { + // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. + if (loopNode.kind === SyntaxKind.DoStatement) { + const loopTokens = loopNode.getChildren(); + + for (let i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], SyntaxKind.WhileKeyword)) { + break; + } + } + } + } + + const breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + + forEach(breaksAndContinues, statement => { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), SyntaxKind.BreakKeyword, SyntaxKind.ContinueKeyword); + } + }); + + return keywords; + } + + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement: BreakOrContinueStatement): Node[] { + const owner = getBreakOrContinueOwner(breakOrContinueStatement); + + if (owner) { + switch (owner.kind) { + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + return getLoopBreakContinueOccurrences(owner); + case SyntaxKind.SwitchStatement: + return getSwitchCaseDefaultOccurrences(owner); + + } + } + + return undefined; + } + + function getSwitchCaseDefaultOccurrences(switchStatement: SwitchStatement): Node[] { + const keywords: Node[] = []; + + pushKeywordIf(keywords, switchStatement.getFirstToken(), SyntaxKind.SwitchKeyword); + + // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. + forEach(switchStatement.caseBlock.clauses, clause => { + pushKeywordIf(keywords, clause.getFirstToken(), SyntaxKind.CaseKeyword, SyntaxKind.DefaultKeyword); + + const breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + + forEach(breaksAndContinues, statement => { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), SyntaxKind.BreakKeyword); + } + }); + }); + + return keywords; + } + + function getTryCatchFinallyOccurrences(tryStatement: TryStatement, sourceFile: SourceFile): Node[] { + const keywords: Node[] = []; + + pushKeywordIf(keywords, tryStatement.getFirstToken(), SyntaxKind.TryKeyword); + + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), SyntaxKind.CatchKeyword); + } + + if (tryStatement.finallyBlock) { + const finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile); + pushKeywordIf(keywords, finallyKeyword, SyntaxKind.FinallyKeyword); + } + + return keywords; + } + + function getThrowOccurrences(throwStatement: ThrowStatement): Node[] { + const owner = getThrowStatementOwner(throwStatement); + + if (!owner) { + return undefined; + } + + const keywords: Node[] = []; + + forEach(aggregateOwnedThrowStatements(owner), throwStatement => { + pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.ThrowKeyword); + }); + + // If the "owner" is a function, then we equate 'return' and 'throw' statements in their + // ability to "jump out" of the function, and include occurrences for both. + if (isFunctionBlock(owner)) { + forEachReturnStatement(owner, returnStatement => { + pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword); + }); + } + + return keywords; + } + + function getReturnOccurrences(returnStatement: ReturnStatement): Node[] { + const func = getContainingFunction(returnStatement); + + // If we didn't find a containing function with a block body, bail out. + if (!(func && hasKind(func.body, SyntaxKind.Block))) { + return undefined; + } + + const keywords: Node[] = []; + forEachReturnStatement(func.body, returnStatement => { + pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword); + }); + + // Include 'throw' statements that do not occur within a try block. + forEach(aggregateOwnedThrowStatements(func.body), throwStatement => { + pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.ThrowKeyword); + }); + + return keywords; + } + + function getIfElseOccurrences(ifStatement: IfStatement, sourceFile: SourceFile): HighlightSpan[] { + const keywords: Node[] = []; + + // Traverse upwards through all parent if-statements linked by their else-branches. + while (hasKind(ifStatement.parent, SyntaxKind.IfStatement) && (ifStatement.parent).elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + + // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. + while (ifStatement) { + const children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], SyntaxKind.IfKeyword); + + // Generally the 'else' keyword is second-to-last, so we traverse backwards. + for (let i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], SyntaxKind.ElseKeyword)) { + break; + } + } + + if (!hasKind(ifStatement.elseStatement, SyntaxKind.IfStatement)) { + break; + } + + ifStatement = ifStatement.elseStatement; + } + + const result: HighlightSpan[] = []; + + // We'd like to highlight else/ifs together if they are only separated by whitespace + // (i.e. the keywords are separated by no comments, no newlines). + for (let i = 0; i < keywords.length; i++) { + if (keywords[i].kind === SyntaxKind.ElseKeyword && i < keywords.length - 1) { + const elseKeyword = keywords[i]; + const ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. + + let shouldCombindElseAndIf = true; + + // Avoid recalculating getStart() by iterating backwards. + for (let j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: HighlightSpanKind.reference + }); + i++; // skip the next keyword + continue; + } + } + + // Ordinary case: just highlight the keyword. + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + + return result; + } + /** * Whether or not a 'node' is preceded by a label of the given string. * Note: 'node' cannot be a SourceFile. From b4c15982ff1caceedc496e6fbdee276a793de554 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Wed, 18 Jan 2017 14:57:20 +0800 Subject: [PATCH 133/175] fix #13556: enable rest/spread on `object` --- src/compiler/checker.ts | 4 ++-- .../nonPrimitiveAccessProperty.errors.txt | 8 +++++++- .../reference/nonPrimitiveAccessProperty.js | 14 ++++++++++++++ tests/baselines/reference/objectSpread.js | 4 ++++ tests/baselines/reference/objectSpread.symbols | 4 ++++ tests/baselines/reference/objectSpread.types | 7 +++++++ .../reference/objectSpreadNegative.errors.txt | 14 +++++++++++--- tests/baselines/reference/objectSpreadNegative.js | 9 +++++++++ .../nonPrimitive/nonPrimitiveAccessProperty.ts | 3 +++ .../cases/conformance/types/spread/objectSpread.ts | 2 ++ .../types/spread/objectSpreadNegative.ts | 5 +++++ 11 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 963d2e77c1b..97ca01bc086 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -11784,7 +11784,7 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined | TypeFlags.NonPrimitive) || type.flags & TypeFlags.Object && !isGenericMappedType(type) || type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } diff --git a/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt b/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt index 8ef94c64448..0a6dfa66b86 100644 --- a/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt +++ b/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt @@ -1,10 +1,16 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(3,3): error TS2339: Property 'nonExist' does not exist on type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(5,7): error TS2459: Type 'object' has no property 'destructuring' and no string index signature. -==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (1 errors) ==== +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (2 errors) ==== var a: object; a.toString(); a.nonExist(); // error ~~~~~~~~ !!! error TS2339: Property 'nonExist' does not exist on type 'object'. + + var { destructuring } = a; // error + ~~~~~~~~~~~~~ +!!! error TS2459: Type 'object' has no property 'destructuring' and no string index signature. + var { ...rest } = a; // ok \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAccessProperty.js b/tests/baselines/reference/nonPrimitiveAccessProperty.js index a71b2aba865..abfe2605e32 100644 --- a/tests/baselines/reference/nonPrimitiveAccessProperty.js +++ b/tests/baselines/reference/nonPrimitiveAccessProperty.js @@ -2,9 +2,23 @@ var a: object; a.toString(); a.nonExist(); // error + +var { destructuring } = a; // error +var { ...rest } = a; // ok //// [nonPrimitiveAccessProperty.js] +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +}; var a; a.toString(); a.nonExist(); // error +var destructuring = a.destructuring; // error +var rest = __rest(a, []); // ok diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index 4305e17ab31..259b86628a5 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -78,6 +78,8 @@ let computedAfter: { a: number, b: string, "at the end": number } = // shortcut syntax let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } +// non primitive +let spreadNonPrimitve = { ...{}} @@ -148,4 +150,6 @@ var computedAfter = __assign({}, o, (_c = { b: 'yeah' }, _c['at the end'] = 14, // shortcut syntax var a = 12; var shortCutted = __assign({}, o, { a: a }); +// non primitive +var spreadNonPrimitve = __assign({}, {}); var _a, _b, _c; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 35c10faa9c0..69c9ed34341 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -316,4 +316,8 @@ let shortCutted: { a: number, b: string } = { ...o, a } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >a : Symbol(a, Decl(objectSpread.ts, 78, 51)) +// non primitive +let spreadNonPrimitve = { ...{}} +>spreadNonPrimitve : Symbol(spreadNonPrimitve, Decl(objectSpread.ts, 80, 3)) + diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index a571bd0bb63..8a8df1a497f 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -407,4 +407,11 @@ let shortCutted: { a: number, b: string } = { ...o, a } >o : { a: number; b: string; } >a : number +// non primitive +let spreadNonPrimitve = { ...{}} +>spreadNonPrimitve : { constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: string): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: string): boolean; } +>{ ...{}} : { constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: string): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: string): boolean; } +>{} : object +>{} : {} + diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 17f07bc06a2..2b0960996ff 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -14,11 +14,12 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,19): error TS269 tests/cases/conformance/types/spread/objectSpreadNegative.ts(42,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/types/spread/objectSpreadNegative.ts(46,12): error TS2339: Property 'b' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(56,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(57,11): error TS2339: Property 'a' does not exist on type '{ constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: string): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: string): boolean; }'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(64,14): error TS2698: Spread types may only be created from object types. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (15 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (16 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -101,6 +102,13 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS269 ~ !!! error TS2339: Property 'm' does not exist on type '{ p: number; }'. + // non primitive + let obj: object = { a: 123 }; + let spreadObj = { ...obj }; + spreadObj.a; // error 'a' is not in {} + ~ +!!! error TS2339: Property 'a' does not exist on type '{ constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: string): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: string): boolean; }'. + // generics function f(t: T, u: U) { return { ...t, ...u, id: 'id' }; diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index dff84355370..fd834b6ef9c 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -52,6 +52,11 @@ let c: C = new C() let spreadC = { ...c } spreadC.m(); // error 'm' is not in '{ ... c }' +// non primitive +let obj: object = { a: 123 }; +let spreadObj = { ...obj }; +spreadObj.a; // error 'a' is not in {} + // generics function f(t: T, u: U) { return { ...t, ...u, id: 'id' }; @@ -132,6 +137,10 @@ var C = (function () { var c = new C(); var spreadC = __assign({}, c); spreadC.m(); // error 'm' is not in '{ ... c }' +// non primitive +var obj = { a: 123 }; +var spreadObj = __assign({}, obj); +spreadObj.a; // error 'a' is not in {} // generics function f(t, u) { return __assign({}, t, u, { id: 'id' }); diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts index 2febbb1e2ca..cf902c12e65 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts @@ -1,3 +1,6 @@ var a: object; a.toString(); a.nonExist(); // error + +var { destructuring } = a; // error +var { ...rest } = a; // ok diff --git a/tests/cases/conformance/types/spread/objectSpread.ts b/tests/cases/conformance/types/spread/objectSpread.ts index ebf2bdb2ade..c4562e6f196 100644 --- a/tests/cases/conformance/types/spread/objectSpread.ts +++ b/tests/cases/conformance/types/spread/objectSpread.ts @@ -78,4 +78,6 @@ let computedAfter: { a: number, b: string, "at the end": number } = // shortcut syntax let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } +// non primitive +let spreadNonPrimitve = { ...{}} diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index 6d1e0dde429..c3b42b31aa9 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -52,6 +52,11 @@ let c: C = new C() let spreadC = { ...c } spreadC.m(); // error 'm' is not in '{ ... c }' +// non primitive +let obj: object = { a: 123 }; +let spreadObj = { ...obj }; +spreadObj.a; // error 'a' is not in {} + // generics function f(t: T, u: U) { return { ...t, ...u, id: 'id' }; From 2d232c21a2ab611b551af967459ac6e25431f9e8 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 17 Jan 2017 10:29:54 -0800 Subject: [PATCH 134/175] Support find-all-references for type keywords --- src/harness/fourslash.ts | 6 +- src/services/documentHighlights.ts | 18 +- src/services/findAllReferences.ts | 191 ++++++++++-------- src/services/services.ts | 31 ++- src/services/types.ts | 2 +- src/services/utilities.ts | 22 +- tests/cases/fourslash/findAllRefsPrimitive.ts | 33 +++ tests/cases/fourslash/fourslash.ts | 1 + tests/cases/fourslash/getOccurrencesOfAny.ts | 12 -- tests/cases/fourslash/localGetReferences.ts | 6 +- 10 files changed, 191 insertions(+), 131 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsPrimitive.ts delete mode 100644 tests/cases/fourslash/getOccurrencesOfAny.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 1afb6de2cf2..6e9ab502e52 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1668,7 +1668,7 @@ namespace FourSlash { this.goToPosition(len); } - private goToRangeStart({fileName, start}: Range) { + public goToRangeStart({fileName, start}: Range) { this.openFile(fileName); this.goToPosition(start); } @@ -3082,6 +3082,10 @@ namespace FourSlashInterface { this.state.goToMarker(name); } + public rangeStart(range: FourSlash.Range) { + this.state.goToRangeStart(range); + } + public bof() { this.state.goToBOF(); } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 79fa0236bc5..778a007ded5 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -17,25 +17,11 @@ namespace ts.DocumentHighlights { } function getSemanticDocumentHighlights(node: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] { - if (node.kind === SyntaxKind.Identifier || - node.kind === SyntaxKind.ThisKeyword || - node.kind === SyntaxKind.ThisType || - node.kind === SyntaxKind.SuperKeyword || - node.kind === SyntaxKind.StringLiteral || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/false); - return convertReferencedSymbols(referencedSymbols); - } - - return undefined; + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/false, /*findInComments*/false, /*implementations*/false); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); } function convertReferencedSymbols(referencedSymbols: ReferencedSymbol[]): DocumentHighlights[] { - if (!referencedSymbols) { - return undefined; - } - const fileNameToDocumentHighlights = createMap(); const result: DocumentHighlights[] = []; for (const referencedSymbol of referencedSymbols) { diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 090357a56b2..68eb684fe25 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1,29 +1,16 @@ /* @internal */ namespace ts.FindAllReferences { - export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { + export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] | undefined { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - if (node === sourceFile) { - return undefined; - } - - switch (node.kind) { - case SyntaxKind.NumericLiteral: - if (!isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - // Fallthrough - case SyntaxKind.Identifier: - case SyntaxKind.ThisKeyword: - // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case SyntaxKind.ConstructorKeyword: - case SyntaxKind.StringLiteral: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/false); } - export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[] { + export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[] | undefined { if (!implementations) { + if (isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + // Labels if (isLabelName(node)) { if (isJumpStatementTarget(node)) { @@ -68,8 +55,6 @@ namespace ts.FindAllReferences { return undefined; } - let result: ReferencedSymbol[]; - // Compute the meaning from the location and the symbol it references const searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); @@ -84,6 +69,7 @@ namespace ts.FindAllReferences { // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. const symbolToIndex: number[] = []; + let result: ReferencedSymbol[]; if (scope) { result = []; getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken); @@ -92,10 +78,7 @@ namespace ts.FindAllReferences { const internedName = getInternedName(symbol, node); for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - - const nameTable = getNameTable(sourceFile); - - if (nameTable.get(internedName) !== undefined) { + if (sourceFileHasName(sourceFile, internedName)) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken); } @@ -105,9 +88,13 @@ namespace ts.FindAllReferences { return result; } + function sourceFileHasName(sourceFile: SourceFile, name: string): boolean { + return getNameTable(sourceFile).get(name) !== undefined; + } + function getDefinition(symbol: Symbol, node: Node, typeChecker: TypeChecker): ReferencedSymbolDefinitionInfo { - const info = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node); - const name = map(info.displayParts, p => p.text).join(""); + const { displayParts, symbolKind } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node); + const name = displayParts.map(p => p.text).join(""); const declarations = symbol.declarations; if (!declarations || declarations.length === 0) { return undefined; @@ -117,10 +104,10 @@ namespace ts.FindAllReferences { containerKind: "", containerName: "", name, - kind: info.symbolKind, + kind: symbolKind, fileName: declarations[0].getSourceFile().fileName, textSpan: createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts + displayParts }; } @@ -351,6 +338,45 @@ namespace ts.FindAllReferences { } } + function getAllReferencesForKeyword(sourceFiles: SourceFile[], keywordKind: ts.SyntaxKind, cancellationToken: CancellationToken): ReferencedSymbol[] { + const name = tokenToString(keywordKind); + const definition: ReferencedSymbolDefinitionInfo = { + containerKind: "", + containerName: "", + fileName: "", + kind: ScriptElementKind.keyword, + name, + textSpan: createTextSpan(0, 1), + displayParts: [{ text: name, kind: ScriptElementKind.keyword }] + } + + const references: ReferenceEntry[] = []; + for (const sourceFile of sourceFiles) { + cancellationToken.throwIfCancellationRequested(); + if (sourceFileHasName(sourceFile, name)) { + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + } + + return [{ definition, references }]; + } + + function addReferencesForKeywordInFile(sourceFile: SourceFile, kind: SyntaxKind, searchText: string, cancellationToken: CancellationToken, references: Push): void { + 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, + }); + } + } + } + /** Search within node "container" for references for a search value, where the search value is defined as a * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). * searchLocation: a node where the search value @@ -375,67 +401,64 @@ namespace ts.FindAllReferences { const parents = getParentSymbolsOfPropertyAccess(); const inheritsFromCache: Map = createMap(); + // Build the set of symbols to search for, initially it has only the current symbol + const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation, typeChecker, implementations); - if (possiblePositions.length) { - // Build the set of symbols to search for, initially it has only the current symbol - const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation, typeChecker, implementations); + for (const position of possiblePositions) { + cancellationToken.throwIfCancellationRequested(); - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); + const referenceLocation = getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + // This wasn't the start of a token. Check to see if it might be a + // match in a comment or string if that's what the caller is asking + // for. + if (!implementations && ((findInStrings && isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position)))) { - const referenceLocation = getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a - // match in a comment or string if that's what the caller is asking - // for. - if (!implementations && ((findInStrings && isInString(sourceFile, position)) || - (findInComments && isInNonReferenceComment(sourceFile, position)))) { - - // In the case where we're looking inside comments/strings, we don't have - // an actual definition. So just use 'undefined' here. Features like - // 'Rename' won't care (as they ignore the definitions), and features like - // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; + // In the case where we're looking inside comments/strings, we don't have + // an actual definition. So just use 'undefined' here. Features like + // 'Rename' won't care (as they ignore the definitions), and features like + // 'FindReferences' will just filter out these results. + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); } + continue; + } - if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; + if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + + const referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache, typeChecker); + + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } - - const referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache, typeChecker); - - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment - * has two meaning : property name and property value. Therefore when we do findAllReference at the position where - * an identifier is declared, the language service should return the position of the variable declaration as well as - * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the - * position of property accessing, the referenceEntry of such position will be handled in the first case. - */ - else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } + /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment + * has two meaning : property name and property value. Therefore when we do findAllReference at the position where + * an identifier is declared, the language service should return the position of the variable declaration as well as + * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the + * position of property accessing, the referenceEntry of such position will be handled in the first case. + */ + else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } - }); + else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } } return; diff --git a/src/services/services.ts b/src/services/services.ts index 26374eccbfd..20204165328 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1959,11 +1959,9 @@ namespace ts { function walk(node: Node) { switch (node.kind) { - case SyntaxKind.Identifier: { - const text = (node).text; - nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + case SyntaxKind.Identifier: + setNameTable((node).text, node); break; - } case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: // We want to store any numbers/strings if they were a name that could be @@ -1974,20 +1972,31 @@ namespace ts { node.parent.kind === SyntaxKind.ExternalModuleReference || isArgumentOfElementAccessExpression(node) || isLiteralComputedPropertyDeclarationName(node)) { - - const text = (node).text; - nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + setNameTable((node).text, node); } break; - default: + case SyntaxKind.TypeOperator: + setNameTable(tokenToString((node as ts.TypeOperatorNode).operator), node); forEachChild(node, walk); - if (node.jsDoc) { - for (const jsDoc of node.jsDoc) { - forEachChild(jsDoc, walk); + break; + default: + if (isTypeKeyword(node.kind)) { + setNameTable(tokenToString(node.kind), node); + } + else { + forEachChild(node, walk); + if (node.jsDoc) { + for (const jsDoc of node.jsDoc) { + forEachChild(jsDoc, walk); + } } } } } + + function setNameTable(text: string, node: ts.Node): void { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } function isArgumentOfElementAccessExpression(node: Node) { diff --git a/src/services/types.ts b/src/services/types.ts index 88ffe2950ce..42f2a7992bd 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -495,7 +495,7 @@ namespace ts { export interface SymbolDisplayPart { text: string; - kind: string; + kind: string; // A ScriptElementKind } export interface QuickInfo { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index def7ab8e4bd..dd337238da3 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -71,7 +71,10 @@ namespace ts { } export function getMeaningFromLocation(node: Node): SemanticMeaning { - if (node.parent.kind === SyntaxKind.ExportAssignment) { + if (node.kind === SyntaxKind.SourceFile) { + return SemanticMeaning.Value; + } + else if (node.parent.kind === SyntaxKind.ExportAssignment) { return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace; } else if (isInRightSideOfImport(node)) { @@ -1116,6 +1119,23 @@ namespace ts { export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); } + + export function isTypeKeyword(kind: SyntaxKind): boolean { + switch (kind) { + case SyntaxKind.AnyKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.NeverKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.KeyOfKeyword: + case SyntaxKind.ObjectKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.VoidKeyword: + return true; + default: + return false; + } + } } // Display-part writer helpers diff --git a/tests/cases/fourslash/findAllRefsPrimitive.ts b/tests/cases/fourslash/findAllRefsPrimitive.ts new file mode 100644 index 00000000000..9bd3d62eabb --- /dev/null +++ b/tests/cases/fourslash/findAllRefsPrimitive.ts @@ -0,0 +1,33 @@ +// @noLib: true + +/// + +// @Filename: a.ts +////const x: [|any|] = 0; +////const any = 2; +////const y: [|any|] = any; + +////function f(b: [|boolean|]): [|boolean|]; + +////type T = [|never|]; type U = [|never|]; + +////function n(x: [|number|]): [|number|]; + +////function o(x: [|object|]): [|object|]; + +////function s(x: [|string|]): [|string|]; + +////function sy(s: [|symbol|]): [|symbol|]; + +////function v(v: [|void|]): [|void|]; + +////function k(x: [|keyof|] Date): [|keyof|] Date; + +// @Filename: b.ts +// const z: [|any|] = 0; + +verify.rangesWithSameTextReferenceEachOther(); +verify.rangesWithSameTextAreDocumentHighlights(); + +goTo.rangeStart(test.ranges()[0]); +verify.renameInfoFailed(); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index ed09fcd2c92..d0293585a4e 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -118,6 +118,7 @@ declare namespace FourSlashInterface { } class goTo { marker(name?: string): void; + rangeStart(range: Range): void; bof(): void; eof(): void; implementation(): void; diff --git a/tests/cases/fourslash/getOccurrencesOfAny.ts b/tests/cases/fourslash/getOccurrencesOfAny.ts deleted file mode 100644 index c28dd83b422..00000000000 --- a/tests/cases/fourslash/getOccurrencesOfAny.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -////var obj1: { -//// (bar: any): any; -//// new (bar: any): any; -//// [bar: any]: any; -//// bar: any; -//// foob(bar: any): an/**/y; -////}; - -goTo.marker(); -verify.occurrencesAtPositionCount(0); diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index fa9e59cabcf..d8e64be1ada 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -3,7 +3,7 @@ // @Filename: localGetReferences_1.ts ////// Comment Refence Test: g/*1*/lobalVar ////// References to a variable declared in global. -////var [|globalVar|]: n/*2*/umber = 2; +////var [|globalVar|]: number = 2; //// ////class fooCls { //// // References to static variable declared in a class. @@ -189,10 +189,6 @@ goTo.marker("1"); verify.referencesAre([]); -// References to type. -goTo.marker("2"); -verify.referencesAre([]); - // References to unresolved symbol. goTo.marker("3"); verify.referencesAre([]); From 9665f2501158d8c765d27bd315dcace9b59d1758 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 18 Jan 2017 13:55:31 -0800 Subject: [PATCH 135/175] Simplify fourslash tests by adding some helpers --- src/harness/fourslash.ts | 72 +++++++++++++++++-- ...tIdentifierDefinitionLocations_Generics.ts | 6 +- ...stAtIdentifierDefinitionLocations_catch.ts | 6 +- ...AtIdentifierDefinitionLocations_classes.ts | 5 +- ...tifierDefinitionLocations_destructuring.ts | 5 +- ...entifierDefinitionLocations_enumMembers.ts | 6 +- ...ntifierDefinitionLocations_enumMembers2.ts | 5 +- ...stAtIdentifierDefinitionLocations_enums.ts | 5 +- ...IdentifierDefinitionLocations_functions.ts | 6 +- ...ierDefinitionLocations_interfaceMembers.ts | 5 +- ...erDefinitionLocations_interfaceMembers2.ts | 5 +- ...erDefinitionLocations_interfaceMembers3.ts | 5 +- ...dentifierDefinitionLocations_interfaces.ts | 6 +- ...dentifierDefinitionLocations_parameters.ts | 6 +- ...dentifierDefinitionLocations_properties.ts | 3 +- ...fierDefinitionLocations_varDeclarations.ts | 5 +- .../completionListAtInvalidLocations.ts | 5 +- ...stBuilderLocations_VariableDeclarations.ts | 9 +-- ...mpletionListBuilderLocations_parameters.ts | 4 +- ...mpletionListBuilderLocations_properties.ts | 5 +- .../completionListInIndexSignature01.ts | 5 +- .../completionListInIndexSignature02.ts | 5 +- .../completionListInObjectLiteral4.ts | 6 +- .../completionListInStringLiterals1.ts | 6 +- .../completionListInStringLiterals2.ts | 6 +- .../completionListInTemplateLiteralParts1.ts | 6 +- ...ionListInTemplateLiteralPartsNegatives1.ts | 6 +- ...ionListNewIdentifierFunctionDeclaration.ts | 3 +- ...ionListNewIdentifierVariableDeclaration.ts | 5 +- .../docCommentTemplateInSingleLineComment.ts | 7 +- ...ommentTemplateInsideFunctionDeclaration.ts | 5 +- .../fourslash/docCommentTemplateRegex.ts | 5 +- tests/cases/fourslash/fourslash.ts | 7 +- .../fourslash/getOccurrencesAbstract01.ts | 11 +-- .../fourslash/getOccurrencesAbstract02.ts | 11 +-- ...etOccurrencesClassExpressionConstructor.ts | 9 +-- .../getOccurrencesClassExpressionPrivate.ts | 9 +-- .../getOccurrencesClassExpressionPublic.ts | 9 +-- .../getOccurrencesClassExpressionStatic.ts | 11 +-- ...getOccurrencesClassExpressionStaticThis.ts | 9 +-- .../getOccurrencesClassExpressionThis.ts | 9 +-- .../cases/fourslash/getOccurrencesConst02.ts | 5 +- .../cases/fourslash/getOccurrencesConst03.ts | 5 +- .../fourslash/getOccurrencesConstructor.ts | 12 +--- .../fourslash/getOccurrencesConstructor2.ts | 12 +--- .../cases/fourslash/getOccurrencesDeclare1.ts | 9 +-- .../cases/fourslash/getOccurrencesDeclare2.ts | 9 +-- .../cases/fourslash/getOccurrencesDeclare3.ts | 9 +-- .../cases/fourslash/getOccurrencesExport1.ts | 9 +-- .../cases/fourslash/getOccurrencesExport2.ts | 9 +-- .../cases/fourslash/getOccurrencesExport3.ts | 9 +-- tests/cases/fourslash/getOccurrencesIfElse.ts | 12 +--- .../cases/fourslash/getOccurrencesIfElse2.ts | 9 +-- .../cases/fourslash/getOccurrencesIfElse3.ts | 9 +-- .../fourslash/getOccurrencesIfElseBroken.ts | 8 +-- .../fourslash/getOccurrencesIsWriteAccess.ts | 8 +-- .../getOccurrencesLoopBreakContinue.ts | 15 ++-- .../getOccurrencesLoopBreakContinue2.ts | 15 ++-- .../getOccurrencesLoopBreakContinue3.ts | 15 ++-- .../getOccurrencesLoopBreakContinue4.ts | 15 ++-- .../getOccurrencesLoopBreakContinue5.ts | 15 ++-- .../getOccurrencesLoopBreakContinue6.ts | 8 +-- ...etOccurrencesLoopBreakContinueNegatives.ts | 8 +-- .../getOccurrencesModifiersNegatives1.ts | 6 +- .../getOccurrencesOfAnonymousFunction.ts | 10 +-- .../cases/fourslash/getOccurrencesPrivate1.ts | 9 +-- .../cases/fourslash/getOccurrencesPrivate2.ts | 9 +-- ...etOccurrencesPropertyInAliasedInterface.ts | 8 +-- .../fourslash/getOccurrencesProtected1.ts | 9 +-- .../fourslash/getOccurrencesProtected2.ts | 9 +-- .../cases/fourslash/getOccurrencesPublic1.ts | 9 +-- .../cases/fourslash/getOccurrencesPublic2.ts | 9 +-- tests/cases/fourslash/getOccurrencesReturn.ts | 12 +--- .../cases/fourslash/getOccurrencesReturn2.ts | 12 +--- .../cases/fourslash/getOccurrencesReturn3.ts | 8 +-- .../fourslash/getOccurrencesReturnBroken.ts | 10 +-- .../fourslash/getOccurrencesSetAndGet.ts | 10 +-- .../fourslash/getOccurrencesSetAndGet2.ts | 10 +-- .../fourslash/getOccurrencesSetAndGet3.ts | 10 +-- .../cases/fourslash/getOccurrencesStatic1.ts | 9 +-- .../getOccurrencesStringLiteralTypes.ts | 9 +-- .../fourslash/getOccurrencesStringLiterals.ts | 6 +- tests/cases/fourslash/getOccurrencesSuper.ts | 14 ++-- tests/cases/fourslash/getOccurrencesSuper2.ts | 14 ++-- tests/cases/fourslash/getOccurrencesSuper3.ts | 2 +- .../fourslash/getOccurrencesSuperNegatives.ts | 6 +- .../getOccurrencesSwitchCaseDefault.ts | 10 +-- .../getOccurrencesSwitchCaseDefault2.ts | 10 +-- .../getOccurrencesSwitchCaseDefault3.ts | 9 +-- .../getOccurrencesSwitchCaseDefault4.ts | 15 +--- tests/cases/fourslash/getOccurrencesThis.ts | 14 ++-- tests/cases/fourslash/getOccurrencesThis2.ts | 14 ++-- tests/cases/fourslash/getOccurrencesThis3.ts | 14 ++-- tests/cases/fourslash/getOccurrencesThis4.ts | 14 ++-- tests/cases/fourslash/getOccurrencesThis5.ts | 14 ++-- .../fourslash/getOccurrencesThisNegatives2.ts | 8 +-- tests/cases/fourslash/getOccurrencesThrow.ts | 16 ++--- tests/cases/fourslash/getOccurrencesThrow2.ts | 16 ++--- tests/cases/fourslash/getOccurrencesThrow3.ts | 16 ++--- tests/cases/fourslash/getOccurrencesThrow4.ts | 16 ++--- tests/cases/fourslash/getOccurrencesThrow5.ts | 16 ++--- tests/cases/fourslash/getOccurrencesThrow6.ts | 13 +--- tests/cases/fourslash/getOccurrencesThrow7.ts | 11 +-- tests/cases/fourslash/getOccurrencesThrow8.ts | 11 +-- .../fourslash/quickInfoInvalidLocations.ts | 10 +-- .../fourslash/referencesForIndexProperty2.ts | 4 +- tests/cases/fourslash/referencesInComment.ts | 4 +- tests/cases/fourslash/renameAlias.ts | 6 +- tests/cases/fourslash/renameAlias2.ts | 6 +- tests/cases/fourslash/renameAlias3.ts | 6 +- .../fourslash/renameAliasExternalModule.ts | 7 +- .../fourslash/renameAliasExternalModule2.ts | 7 +- .../fourslash/renameAliasExternalModule3.ts | 7 +- .../renameContextuallyTypedProperties.ts | 7 +- .../renameContextuallyTypedProperties2.ts | 7 +- tests/cases/fourslash/renameDefaultImport.ts | 23 +++--- .../renameDefaultImportDifferentName.ts | 24 +++---- .../renameDestructuringAssignment.ts | 16 ++--- .../renameDestructuringAssignmentInFor2.ts | 26 +++---- .../renameDestructuringAssignmentInForOf2.ts | 26 +++---- ...ucturingAssignmentNestedInArrayLiteral2.ts | 20 +++--- ...nameDestructuringAssignmentNestedInFor2.ts | 13 ++-- ...meDestructuringAssignmentNestedInForOf2.ts | 14 ++-- .../renameDestructuringClassProperty.ts | 14 ++-- .../renameDestructuringDeclarationInFor.ts | 26 +++---- .../renameDestructuringDeclarationInForOf.ts | 24 +++---- .../renameDestructuringFunctionParameter.ts | 11 ++- ...renameDestructuringNestedBindingElement.ts | 14 ++-- .../fourslash/renameForDefaultExport01.ts | 7 +- .../fourslash/renameForDefaultExport02.ts | 7 +- .../fourslash/renameForDefaultExport03.ts | 7 +- .../cases/fourslash/renameImportAndExport.ts | 6 +- .../fourslash/renameImportAndShorthand.ts | 6 +- .../renameImportNamespaceAndShorthand.ts | 6 +- .../fourslash/renameImportOfExportEquals.ts | 6 +- tests/cases/fourslash/renameImportRequire.ts | 12 ++-- .../fourslash/renameInheritedProperties1.ts | 7 +- .../fourslash/renameInheritedProperties2.ts | 7 +- .../fourslash/renameInheritedProperties3.ts | 7 +- .../fourslash/renameInheritedProperties4.ts | 7 +- .../fourslash/renameInheritedProperties5.ts | 8 +-- .../fourslash/renameInheritedProperties6.ts | 7 +- .../fourslash/renameInheritedProperties7.ts | 11 +-- .../fourslash/renameInheritedProperties8.ts | 11 +-- .../renameLocationsForClassExpression01.ts | 8 +-- .../renameLocationsForFunctionExpression01.ts | 7 +- .../renameLocationsForFunctionExpression02.ts | 9 +-- ...enameObjectBindingElementPropertyName01.ts | 5 +- tests/cases/fourslash/renameObjectSpread.ts | 6 +- .../fourslash/renameObjectSpreadAssignment.ts | 10 +-- .../renameParameterPropertyDeclaration1.ts | 7 +- .../renameParameterPropertyDeclaration2.ts | 7 +- .../renameParameterPropertyDeclaration3.ts | 7 +- .../renameParameterPropertyDeclaration4.ts | 7 +- .../renameParameterPropertyDeclaration5.ts | 7 +- tests/cases/fourslash/renameRest.ts | 8 +-- .../fourslash/renameStingPropertyNames.ts | 7 +- .../fourslash/renameStringLiteralTypes.ts | 6 +- tests/cases/fourslash/renameThis.ts | 4 +- .../cases/fourslash/renameUMDModuleAlias1.ts | 6 +- tests/cases/fourslash/server/occurrences01.ts | 11 +-- tests/cases/fourslash/server/occurrences02.ts | 11 +-- .../signatureHelpTaggedTemplates1.ts | 6 +- .../signatureHelpTaggedTemplates2.ts | 6 +- .../signatureHelpTaggedTemplates3.ts | 6 +- .../signatureHelpTaggedTemplates4.ts | 6 +- .../signatureHelpTaggedTemplates5.ts | 6 +- .../signatureHelpTaggedTemplates6.ts | 6 +- .../signatureHelpTaggedTemplates7.ts | 6 +- ...signatureHelpTaggedTemplatesIncomplete1.ts | 8 +-- ...signatureHelpTaggedTemplatesIncomplete2.ts | 6 +- ...signatureHelpTaggedTemplatesIncomplete3.ts | 6 +- ...signatureHelpTaggedTemplatesIncomplete4.ts | 6 +- ...signatureHelpTaggedTemplatesIncomplete5.ts | 6 +- ...signatureHelpTaggedTemplatesIncomplete6.ts | 6 +- ...signatureHelpTaggedTemplatesIncomplete7.ts | 6 +- ...signatureHelpTaggedTemplatesIncomplete8.ts | 6 +- ...signatureHelpTaggedTemplatesIncomplete9.ts | 6 +- .../signatureHelpTaggedTemplatesNegatives1.ts | 7 +- .../signatureHelpTaggedTemplatesNegatives2.ts | 7 +- .../signatureHelpTaggedTemplatesNegatives3.ts | 7 +- .../signatureHelpTaggedTemplatesNegatives4.ts | 7 +- .../signatureHelpTaggedTemplatesNegatives5.ts | 7 +- .../signatureHelpTaggedTemplatesNested1.ts | 6 +- .../signatureHelpTaggedTemplatesNested2.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags1.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags2.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags3.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags4.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags5.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags6.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags7.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags8.ts | 6 +- ...eHelpTaggedTemplatesWithOverloadedTags9.ts | 8 +-- .../completionListGenericConstraintsNames.ts | 9 ++- 195 files changed, 482 insertions(+), 1301 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 1afb6de2cf2..721647df0cd 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -372,8 +372,8 @@ namespace FourSlash { } // Entry points from fourslash.ts - public goToMarker(name = "") { - const marker = this.getMarkerByName(name); + public goToMarker(name: string | Marker = "") { + const marker = typeof name === "string" ? this.getMarkerByName(name) : name; if (this.activeFile.fileName !== marker.fileName) { this.openFile(marker.fileName); } @@ -382,10 +382,37 @@ namespace FourSlash { if (marker.position === -1 || marker.position > content.length) { throw new Error(`Marker "${name}" has been invalidated by unrecoverable edits to the file.`); } - this.lastKnownMarker = name; + const mName = typeof name === "string" ? name : this.markerName(marker); + this.lastKnownMarker = mName; this.goToPosition(marker.position); } + public goToEachMarker(action: () => void) { + const markers = this.getMarkers(); + assert(markers.length); + for (const marker of markers) { + this.goToMarker(marker); + action(); + } + } + + public goToEachRange(action: () => void) { + const ranges = this.getRanges(); + assert(ranges.length); + for (const range of ranges) { + this.goToRangeStart(range); + action(); + } + } + + private markerName(m: Marker): string { + return ts.forEachEntry(this.testData.markerPositions, (marker, name) => { + if (marker === m) { + return name; + } + })!; + } + public goToPosition(pos: number) { this.currentCaretPosition = pos; } @@ -1668,7 +1695,7 @@ namespace FourSlash { this.goToPosition(len); } - private goToRangeStart({fileName, start}: Range) { + public goToRangeStart({fileName, start}: Range) { this.openFile(fileName); this.goToPosition(start); } @@ -2365,6 +2392,21 @@ namespace FourSlash { return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch); } + public verifyRangesAreOccurrences(isWriteAccess?: boolean) { + const ranges = this.getRanges(); + for (const r of ranges) { + this.goToRangeStart(r); + this.verifyOccurrencesAtPositionListCount(ranges.length); + for (const range of ranges) { + this.verifyOccurrencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess); + } + } + } + + public verifyRangesAreRenameLocations(findInStrings: boolean, findInComments: boolean) { + this.goToEachRange(() => this.verifyRenameLocations(findInStrings, findInComments)); + } + public verifyRangesWithSameTextAreDocumentHighlights() { this.rangesByText().forEach(ranges => this.verifyRangesAreDocumentHighlights(ranges)); } @@ -3078,10 +3120,22 @@ namespace FourSlashInterface { // Moves the caret to the specified marker, // or the anonymous marker ('/**/') if no name // is given - public marker(name?: string) { + public marker(name?: string | FourSlash.Marker) { this.state.goToMarker(name); } + public eachMarker(action: () => void) { + this.state.goToEachMarker(action); + } + + public rangeStart(range: FourSlash.Range) { + this.state.goToRangeStart(range); + } + + public eachRange(action: () => void) { + this.state.goToEachRange(action); + } + public bof() { this.state.goToBOF(); } @@ -3432,6 +3486,14 @@ namespace FourSlashInterface { this.state.verifyOccurrencesAtPositionListCount(expectedCount); } + public rangesAreOccurrences(isWriteAccess?: boolean) { + this.state.verifyRangesAreOccurrences(isWriteAccess); + } + + public rangesAreRenameLocations(findInStrings = false, findInComments = false) { + this.state.verifyRangesAreRenameLocations(findInStrings, findInComments); + } + public rangesAreDocumentHighlights(ranges?: FourSlash.Range[]) { this.state.verifyRangesAreDocumentHighlights(ranges); } diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts index 0e92a3ae995..784fc8c499c 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts @@ -11,8 +11,4 @@ ////function A { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts index bdf13c1d97f..bfbfa1bb160 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts @@ -6,8 +6,4 @@ //// try {} catch(a/*catchVariable2*/ - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_classes.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_classes.ts index 60a108cf1e6..5d96c565719 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_classes.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_classes.ts @@ -6,7 +6,4 @@ ////class a/*className2*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts index 7f8ef32e1ad..d2ecdf29426 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts @@ -16,7 +16,4 @@ //// function func2({ a, b/*parameter2*/ -test.markers().forEach(m => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts index 6c0472be546..f0818108301 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts @@ -4,8 +4,4 @@ ////enum a { /*enumValueName1*/ - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers2.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers2.ts index ee2f3e71032..11aa276bb5a 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers2.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers2.ts @@ -3,7 +3,4 @@ ////var aa = 1; ////enum a { foo, /*enumValueName3*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts index 183f8a22c63..c740218e27e 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts @@ -8,7 +8,4 @@ ////var x = 0; enum /*enumName4*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_functions.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_functions.ts index 24231174727..2f55f9527bc 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_functions.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_functions.ts @@ -6,8 +6,4 @@ ////function a/*functionName2*/ - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers.ts index 266b0b78c9c..9998f38c255 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers.ts @@ -4,7 +4,4 @@ ////interface a { /*interfaceValue1*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers2.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers2.ts index 82a30325948..234e41bfb71 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers2.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers2.ts @@ -4,7 +4,4 @@ ////interface a { f/*interfaceValue2*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers3.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers3.ts index ed640dd3f1a..f0a596ef8b1 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers3.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaceMembers3.ts @@ -4,7 +4,4 @@ ////interface a { f; /*interfaceValue3*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts index ec2732fe2fe..d4be268eb7d 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts @@ -6,8 +6,4 @@ ////interface a/*interfaceName2*/ - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts index 10293c41a64..474859129db 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts @@ -22,8 +22,4 @@ ////class bar10{ constructor(...a/*constructorParamter6*/ - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts index 58fdc1d2342..3ba0df0c31d 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts @@ -30,8 +30,7 @@ //// private a/*property7*/ ////} -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); +goTo.eachMarker(() => { verify.not.completionListIsEmpty(); verify.completionListAllowsNewIdentifier(); }); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts index 2e85364ce3c..9a2c9ba664a 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts @@ -11,7 +11,4 @@ ////var a2, a/*varName4*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListAtInvalidLocations.ts b/tests/cases/fourslash/completionListAtInvalidLocations.ts index 6e4b4056a7d..0660f0e183b 100644 --- a/tests/cases/fourslash/completionListAtInvalidLocations.ts +++ b/tests/cases/fourslash/completionListAtInvalidLocations.ts @@ -25,7 +25,4 @@ ////foo; ////var v10 = /reg/*inRegExp1*/ex/; -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts b/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts index d069b9a722e..2562b840995 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts @@ -11,7 +11,7 @@ //// var y : any = "", x = (a/*var5*/ ////class C{} -////var y = new C( +////var y = new C( //// class C{} //// var y = new C(0, /*var7*/ @@ -26,9 +26,4 @@ ////var y = 10; y=/*var12*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListAllowsNewIdentifier(); -}); - - +goTo.eachMarker(() => verify.completionListAllowsNewIdentifier()); diff --git a/tests/cases/fourslash/completionListBuilderLocations_parameters.ts b/tests/cases/fourslash/completionListBuilderLocations_parameters.ts index 12dba953d3d..607ca0d9819 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_parameters.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_parameters.ts @@ -14,9 +14,7 @@ ////class bar7{ constructor(private a, /*constructorParamter6*/ - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); +goTo.eachMarker(() => { verify.not.completionListIsEmpty(); verify.completionListAllowsNewIdentifier(); }); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListBuilderLocations_properties.ts b/tests/cases/fourslash/completionListBuilderLocations_properties.ts index 287ffd6746b..806d8c1de4f 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_properties.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_properties.ts @@ -10,7 +10,4 @@ //// public static a/*property2*/ ////} -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListInIndexSignature01.ts b/tests/cases/fourslash/completionListInIndexSignature01.ts index 2db28505b3e..aaf97fee1a5 100644 --- a/tests/cases/fourslash/completionListInIndexSignature01.ts +++ b/tests/cases/fourslash/completionListInIndexSignature01.ts @@ -14,7 +14,4 @@ //// [x/*5*/yz: number]: boolean; //// [/*6*/ -for (let marker of test.markers()) { - goTo.position(marker.position); - verify.completionListAllowsNewIdentifier(); -} \ No newline at end of file +goTo.eachMarker(() => verify.completionListAllowsNewIdentifier()); diff --git a/tests/cases/fourslash/completionListInIndexSignature02.ts b/tests/cases/fourslash/completionListInIndexSignature02.ts index d3b65dc7759..ce1f8b38e24 100644 --- a/tests/cases/fourslash/completionListInIndexSignature02.ts +++ b/tests/cases/fourslash/completionListInIndexSignature02.ts @@ -13,7 +13,4 @@ ////type T = { //// [xyz: /*5*/ -for (let marker of test.markers()) { - goTo.position(marker.position); - verify.not.completionListAllowsNewIdentifier(); -} \ No newline at end of file +goTo.eachMarker(() => verify.not.completionListAllowsNewIdentifier()); diff --git a/tests/cases/fourslash/completionListInObjectLiteral4.ts b/tests/cases/fourslash/completionListInObjectLiteral4.ts index c00462c8255..3094b4db6ad 100644 --- a/tests/cases/fourslash/completionListInObjectLiteral4.ts +++ b/tests/cases/fourslash/completionListInObjectLiteral4.ts @@ -20,9 +20,7 @@ ////funcE({ /*E*/ }); ////funcF({ /*F*/ }); - -for (const marker of test.markers()) { - goTo.position(marker.position); +goTo.eachMarker(() => { verify.completionListContains("hello"); verify.completionListContains("world"); -} +}); diff --git a/tests/cases/fourslash/completionListInStringLiterals1.ts b/tests/cases/fourslash/completionListInStringLiterals1.ts index e394e8dfe7c..aabcc82eba5 100644 --- a/tests/cases/fourslash/completionListInStringLiterals1.ts +++ b/tests/cases/fourslash/completionListInStringLiterals1.ts @@ -3,8 +3,4 @@ ////"/*1*/ /*2*/\/*3*/ //// /*4*/ \\/*5*/ -test.markers().forEach(marker => { - goTo.position(marker.position); - - verify.completionListIsEmpty() -}); \ No newline at end of file +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListInStringLiterals2.ts b/tests/cases/fourslash/completionListInStringLiterals2.ts index 10cb05a4f91..4ffd5eb8a9b 100644 --- a/tests/cases/fourslash/completionListInStringLiterals2.ts +++ b/tests/cases/fourslash/completionListInStringLiterals2.ts @@ -4,8 +4,4 @@ //// /*4*/ \\\/*5*/ //// /*6*/ -test.markers().forEach(marker => { - goTo.position(marker.position); - - verify.completionListIsEmpty() -}); \ No newline at end of file +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts b/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts index 0166546f63e..9de7b6a6a5b 100644 --- a/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts +++ b/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts @@ -4,8 +4,4 @@ //// /////*6*/`asdasd${/*7*/ 2 + 1.1 /*8*/} 12312 { -test.markers().forEach(marker => { - goTo.position(marker.position); - - verify.completionListItemsCountIsGreaterThan(0) -}); \ No newline at end of file +goTo.eachMarker(() => verify.completionListItemsCountIsGreaterThan(0)); diff --git a/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts b/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts index ac64a41fb56..30af0678e7d 100644 --- a/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts +++ b/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts @@ -4,8 +4,4 @@ //// ////`asdasd$/*7*/{ 2 + 1.1 }/*8*/ 12312 /*9*/{/*10*/ -test.markers().forEach(marker => { - goTo.position(marker.position); - - verify.completionListIsEmpty() -}); \ No newline at end of file +goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts b/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts index 8a9a5bfb9ed..1f8b24d1cf1 100644 --- a/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts +++ b/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts @@ -2,8 +2,7 @@ ////function F(pref: (a/*1*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); +goTo.eachMarker(() => { verify.not.completionListIsEmpty(); verify.completionListAllowsNewIdentifier(); }); diff --git a/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts b/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts index 534011b7ee1..a4126ebe8be 100644 --- a/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts +++ b/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts @@ -4,8 +4,7 @@ ////var y : (s:string, list/*2*/ -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); +goTo.eachMarker(() => { verify.not.completionListIsEmpty(); verify.completionListAllowsNewIdentifier(); -}); \ No newline at end of file +}); diff --git a/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts b/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts index 52925870a66..65e9c17014e 100644 --- a/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts +++ b/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts @@ -3,12 +3,9 @@ // @Filename: justAComment.ts //// // We want to check off-by-one errors in assessing the end of the comment, so we check twice, //// // first with a trailing space and then without. -//// // /*0*/ +//// // /*0*/ //// // /*1*/ //// // We also want to check EOF handling at the end of a comment //// // /*2*/ -test.markers().forEach((marker) => { - goTo.position(marker.position); - verify.noDocCommentTemplate(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.noDocCommentTemplate()); diff --git a/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts b/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts index 9c803301526..dd58a1bfd5f 100644 --- a/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts +++ b/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts @@ -3,7 +3,4 @@ // @Filename: functionDecl.ts ////f/*0*/unction /*1*/foo/*2*/(/*3*/) /*4*/{ /*5*/} -test.markers().forEach((marker) => { - goTo.position(marker.position); - verify.noDocCommentTemplate(); -}); +goTo.eachMarker(() => verify.noDocCommentTemplate()); diff --git a/tests/cases/fourslash/docCommentTemplateRegex.ts b/tests/cases/fourslash/docCommentTemplateRegex.ts index 0bf50f5e85a..62d200dee10 100644 --- a/tests/cases/fourslash/docCommentTemplateRegex.ts +++ b/tests/cases/fourslash/docCommentTemplateRegex.ts @@ -3,7 +3,4 @@ // @Filename: regex.ts ////var regex = /*0*///*1*/asdf/*2*/ /*3*///*4*/; -test.markers().forEach((marker) => { - goTo.position(marker.position); - verify.noDocCommentTemplate(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.noDocCommentTemplate()); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index ed09fcd2c92..6685bbc19c0 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -117,7 +117,10 @@ declare namespace FourSlashInterface { markerByName(s: string): Marker; } class goTo { - marker(name?: string): void; + marker(name?: string | Marker): void; + eachMarker(action: () => void): void; + rangeStart(range: Range): void; + eachRange(action: () => void): void; bof(): void; eof(): void; implementation(): void; @@ -191,6 +194,8 @@ declare namespace FourSlashInterface { * `start` should be included in `references`. */ referencesOf(start: Range, references: Range[]): void; + rangesAreOccurrences(isWriteAccess?: boolean): void; + rangesAreRenameLocations(findInStrings?: boolean, findInComments?: boolean): void; /** * Performs `referencesOf` for every range on the whole set. * If `ranges` is omitted, this is `test.ranges()`. diff --git a/tests/cases/fourslash/getOccurrencesAbstract01.ts b/tests/cases/fourslash/getOccurrencesAbstract01.ts index 3e48ba4841a..b2ccc815e05 100644 --- a/tests/cases/fourslash/getOccurrencesAbstract01.ts +++ b/tests/cases/fourslash/getOccurrencesAbstract01.ts @@ -12,13 +12,4 @@ //// abstract bar(): void; ////} -const ranges = test.ranges(); - -for (let r of ranges) { - goTo.position(r.start); - verify.occurrencesAtPositionCount(ranges.length); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesAbstract02.ts b/tests/cases/fourslash/getOccurrencesAbstract02.ts index 8daafdbdc8e..1decdaaf69c 100644 --- a/tests/cases/fourslash/getOccurrencesAbstract02.ts +++ b/tests/cases/fourslash/getOccurrencesAbstract02.ts @@ -11,16 +11,7 @@ //// abstract bar(): void; ////} -const ranges = test.ranges(); - -for (let r of ranges) { - goTo.position(r.start); - verify.occurrencesAtPositionCount(ranges.length); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); goTo.marker("1"); verify.occurrencesAtPositionCount(0); diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts b/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts index 5fa778ef8cd..d092c1dfd92 100644 --- a/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts +++ b/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts @@ -13,11 +13,4 @@ //// } ////} -const ranges = test.ranges(); -for (let r of ranges) { - goTo.position(r.start); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts b/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts index b008ec237b8..2bc18d2eb25 100644 --- a/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts +++ b/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts @@ -17,11 +17,4 @@ //// public test2() {} ////} -const ranges = test.ranges(); -for (let r of ranges) { - goTo.position(r.start); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionPublic.ts b/tests/cases/fourslash/getOccurrencesClassExpressionPublic.ts index 3070fd4f6ca..c54dbd289e0 100644 --- a/tests/cases/fourslash/getOccurrencesClassExpressionPublic.ts +++ b/tests/cases/fourslash/getOccurrencesClassExpressionPublic.ts @@ -17,11 +17,4 @@ //// public test2() {} ////} -const ranges = test.ranges(); -for (let r of ranges) { - goTo.position(r.start); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts b/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts index 567c0c4eccd..d4851ad86ef 100644 --- a/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts +++ b/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts @@ -1,7 +1,7 @@ /// ////let A = class Foo { -//// public static foo; +//// public [|static|] foo; //// [|static|] a; //// constructor(public y: string, private x: string) { //// } @@ -19,11 +19,4 @@ //// public static test2() {} ////} -const ranges = test.ranges(); -for (let r of ranges) { - goTo.position(r.start); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts b/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts index 5444ab9acdd..53c1a69bead 100644 --- a/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts +++ b/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts @@ -46,11 +46,4 @@ //// } ////} -const ranges = test.ranges(); -for (let r of ranges) { - goTo.position(r.start); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts b/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts index ed8f8cb1d0e..d1331e54a43 100644 --- a/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts +++ b/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts @@ -44,11 +44,4 @@ //// } ////} -const ranges = test.ranges(); -for (let r of ranges) { - goTo.position(r.start); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesConst02.ts b/tests/cases/fourslash/getOccurrencesConst02.ts index 0dc96fcca6c..57d75f88e22 100644 --- a/tests/cases/fourslash/getOccurrencesConst02.ts +++ b/tests/cases/fourslash/getOccurrencesConst02.ts @@ -10,7 +10,4 @@ ////declare [|const|] enum E { ////} -test.ranges().forEach(range => { - goTo.position(range.start); - verify.occurrencesAtPositionCount(0); -}); \ No newline at end of file +goTo.eachRange(() => verify.occurrencesAtPositionCount(0)); diff --git a/tests/cases/fourslash/getOccurrencesConst03.ts b/tests/cases/fourslash/getOccurrencesConst03.ts index 404ff655044..a86481ed72a 100644 --- a/tests/cases/fourslash/getOccurrencesConst03.ts +++ b/tests/cases/fourslash/getOccurrencesConst03.ts @@ -10,7 +10,4 @@ ////export [|const|] enum E { ////} -test.ranges().forEach(range => { - goTo.position(range.start); - verify.occurrencesAtPositionCount(0); -}); \ No newline at end of file +goTo.eachRange(() => verify.occurrencesAtPositionCount(0)); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesConstructor.ts b/tests/cases/fourslash/getOccurrencesConstructor.ts index 0a6b84a5770..41d72c533a3 100644 --- a/tests/cases/fourslash/getOccurrencesConstructor.ts +++ b/tests/cases/fourslash/getOccurrencesConstructor.ts @@ -18,15 +18,9 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesConstructor2.ts b/tests/cases/fourslash/getOccurrencesConstructor2.ts index 049c25b7f52..b34ffa4a190 100644 --- a/tests/cases/fourslash/getOccurrencesConstructor2.ts +++ b/tests/cases/fourslash/getOccurrencesConstructor2.ts @@ -18,15 +18,9 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesDeclare1.ts b/tests/cases/fourslash/getOccurrencesDeclare1.ts index 4207a92b5a6..96114d3fc9d 100644 --- a/tests/cases/fourslash/getOccurrencesDeclare1.ts +++ b/tests/cases/fourslash/getOccurrencesDeclare1.ts @@ -53,11 +53,4 @@ //// [|declare|] function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesDeclare2.ts b/tests/cases/fourslash/getOccurrencesDeclare2.ts index 3d719e5d035..78028d94996 100644 --- a/tests/cases/fourslash/getOccurrencesDeclare2.ts +++ b/tests/cases/fourslash/getOccurrencesDeclare2.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesDeclare3.ts b/tests/cases/fourslash/getOccurrencesDeclare3.ts index 2dee0af4b14..8c1bf7e9658 100644 --- a/tests/cases/fourslash/getOccurrencesDeclare3.ts +++ b/tests/cases/fourslash/getOccurrencesDeclare3.ts @@ -61,11 +61,4 @@ ////[|declare|] module dm { } ////export class EC { } -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesExport1.ts b/tests/cases/fourslash/getOccurrencesExport1.ts index bc82e8a1bea..71202a820a7 100644 --- a/tests/cases/fourslash/getOccurrencesExport1.ts +++ b/tests/cases/fourslash/getOccurrencesExport1.ts @@ -53,11 +53,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesExport2.ts b/tests/cases/fourslash/getOccurrencesExport2.ts index a8e43e744b9..442642d77ec 100644 --- a/tests/cases/fourslash/getOccurrencesExport2.ts +++ b/tests/cases/fourslash/getOccurrencesExport2.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesExport3.ts b/tests/cases/fourslash/getOccurrencesExport3.ts index 215cbf8f48a..04ee55bb1e6 100644 --- a/tests/cases/fourslash/getOccurrencesExport3.ts +++ b/tests/cases/fourslash/getOccurrencesExport3.ts @@ -61,11 +61,4 @@ ////declare module dm { } ////[|export|] class EC { } -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesIfElse.ts b/tests/cases/fourslash/getOccurrencesIfElse.ts index 96c70d404ab..9251a59d130 100644 --- a/tests/cases/fourslash/getOccurrencesIfElse.ts +++ b/tests/cases/fourslash/getOccurrencesIfElse.ts @@ -22,15 +22,9 @@ ////} ////[|else|] { } -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesIfElse2.ts b/tests/cases/fourslash/getOccurrencesIfElse2.ts index 012e7a96efd..df77687aac6 100644 --- a/tests/cases/fourslash/getOccurrencesIfElse2.ts +++ b/tests/cases/fourslash/getOccurrencesIfElse2.ts @@ -22,11 +22,4 @@ ////} ////else { } - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); \ No newline at end of file +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesIfElse3.ts b/tests/cases/fourslash/getOccurrencesIfElse3.ts index b0ca3615648..aec1a6911af 100644 --- a/tests/cases/fourslash/getOccurrencesIfElse3.ts +++ b/tests/cases/fourslash/getOccurrencesIfElse3.ts @@ -22,11 +22,4 @@ ////} ////else { } - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); \ No newline at end of file +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesIfElseBroken.ts b/tests/cases/fourslash/getOccurrencesIfElseBroken.ts index a9e1e94f42d..c5460b3e634 100644 --- a/tests/cases/fourslash/getOccurrencesIfElseBroken.ts +++ b/tests/cases/fourslash/getOccurrencesIfElseBroken.ts @@ -12,13 +12,7 @@ // It would be nice if in the future, // We could include that last 'else'. -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); verify.occurrencesAtPositionCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesIsWriteAccess.ts b/tests/cases/fourslash/getOccurrencesIsWriteAccess.ts index 1ba4c39041c..e31b199217f 100644 --- a/tests/cases/fourslash/getOccurrencesIsWriteAccess.ts +++ b/tests/cases/fourslash/getOccurrencesIsWriteAccess.ts @@ -18,10 +18,8 @@ ////[|{| "isWriteAccess": true |}x|] += 1; ////[|{| "isWriteAccess": true |}x|] <<= 1; +goTo.rangeStart(test.ranges()[0]); -var firstRange = test.ranges()[0]; -goTo.position(firstRange.start, firstRange.fileName); - -test.ranges().forEach((range) => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, range.marker.data.isWriteAccess); -}); +} diff --git a/tests/cases/fourslash/getOccurrencesLoopBreakContinue.ts b/tests/cases/fourslash/getOccurrencesLoopBreakContinue.ts index 81aaaed5c58..88621cd4cf4 100644 --- a/tests/cases/fourslash/getOccurrencesLoopBreakContinue.ts +++ b/tests/cases/fourslash/getOccurrencesLoopBreakContinue.ts @@ -46,7 +46,7 @@ //// default: //// continue; //// } -//// +//// //// // these cross function boundaries //// break label1; //// continue label1; @@ -63,17 +63,10 @@ //// ////label7: while (true) continue label5; -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); verify.occurrencesAtPositionCount(test.ranges().length); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesLoopBreakContinue2.ts b/tests/cases/fourslash/getOccurrencesLoopBreakContinue2.ts index 51d4d89b657..225346f8077 100644 --- a/tests/cases/fourslash/getOccurrencesLoopBreakContinue2.ts +++ b/tests/cases/fourslash/getOccurrencesLoopBreakContinue2.ts @@ -46,7 +46,7 @@ //// default: //// continue; //// } -//// +//// //// // these cross function boundaries //// break label1; //// continue label1; @@ -63,17 +63,10 @@ //// ////label7: while (true) continue label5; -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); verify.occurrencesAtPositionCount(test.ranges().length); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesLoopBreakContinue3.ts b/tests/cases/fourslash/getOccurrencesLoopBreakContinue3.ts index 8777c912afd..c1aeef315f9 100644 --- a/tests/cases/fourslash/getOccurrencesLoopBreakContinue3.ts +++ b/tests/cases/fourslash/getOccurrencesLoopBreakContinue3.ts @@ -46,7 +46,7 @@ //// default: //// continue; //// } -//// +//// //// // these cross function boundaries //// break label1; //// continue label1; @@ -63,16 +63,9 @@ //// ////label7: while (true) continue label5; -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesLoopBreakContinue4.ts b/tests/cases/fourslash/getOccurrencesLoopBreakContinue4.ts index 1bca62ba013..b183b2b3fde 100644 --- a/tests/cases/fourslash/getOccurrencesLoopBreakContinue4.ts +++ b/tests/cases/fourslash/getOccurrencesLoopBreakContinue4.ts @@ -46,7 +46,7 @@ //// default: //// [|continue|]; //// } -//// +//// //// // these cross function boundaries //// break label1; //// continue label1; @@ -63,17 +63,10 @@ //// ////label7: while (true) continue label5; -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); verify.occurrencesAtPositionCount(test.ranges().length); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesLoopBreakContinue5.ts b/tests/cases/fourslash/getOccurrencesLoopBreakContinue5.ts index f4e62c554e4..3353d6c96dc 100644 --- a/tests/cases/fourslash/getOccurrencesLoopBreakContinue5.ts +++ b/tests/cases/fourslash/getOccurrencesLoopBreakContinue5.ts @@ -46,7 +46,7 @@ //// default: //// continue; //// } -//// +//// //// // these cross function boundaries //// break label1; //// continue label1; @@ -63,17 +63,10 @@ //// ////label7: while (true) continue label5; -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); verify.occurrencesAtPositionCount(test.ranges().length); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesLoopBreakContinue6.ts b/tests/cases/fourslash/getOccurrencesLoopBreakContinue6.ts index 0127245dd50..957f8c4af01 100644 --- a/tests/cases/fourslash/getOccurrencesLoopBreakContinue6.ts +++ b/tests/cases/fourslash/getOccurrencesLoopBreakContinue6.ts @@ -46,7 +46,7 @@ //// default: //// continue; //// } -//// +//// //// // these cross function boundaries //// br/*5*/eak label1; //// co/*6*/ntinue label1; @@ -63,8 +63,4 @@ //// ////label7: while (true) co/*10*/ntinue label5; -test.markers().forEach(m => { - goTo.position(m.position); - - verify.occurrencesAtPositionCount(0); -}); +goTo.eachMarker(() => verify.occurrencesAtPositionCount(0)); diff --git a/tests/cases/fourslash/getOccurrencesLoopBreakContinueNegatives.ts b/tests/cases/fourslash/getOccurrencesLoopBreakContinueNegatives.ts index 0127245dd50..957f8c4af01 100644 --- a/tests/cases/fourslash/getOccurrencesLoopBreakContinueNegatives.ts +++ b/tests/cases/fourslash/getOccurrencesLoopBreakContinueNegatives.ts @@ -46,7 +46,7 @@ //// default: //// continue; //// } -//// +//// //// // these cross function boundaries //// br/*5*/eak label1; //// co/*6*/ntinue label1; @@ -63,8 +63,4 @@ //// ////label7: while (true) co/*10*/ntinue label5; -test.markers().forEach(m => { - goTo.position(m.position); - - verify.occurrencesAtPositionCount(0); -}); +goTo.eachMarker(() => verify.occurrencesAtPositionCount(0)); diff --git a/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts b/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts index 51d5907a5d6..836d87fa9be 100644 --- a/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts +++ b/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts @@ -34,8 +34,4 @@ ////[|public|] [|static|] [|protected|] [|private|] f; ////[|protected|] [|static|] [|public|] g; - -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(0); -}); +goTo.eachRange(() => verify.occurrencesAtPositionCount(0)); diff --git a/tests/cases/fourslash/getOccurrencesOfAnonymousFunction.ts b/tests/cases/fourslash/getOccurrencesOfAnonymousFunction.ts index 96354df6b05..8ce60b21306 100644 --- a/tests/cases/fourslash/getOccurrencesOfAnonymousFunction.ts +++ b/tests/cases/fourslash/getOccurrencesOfAnonymousFunction.ts @@ -5,12 +5,4 @@ //// return 0; ////}) - -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(2); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range); - }); -}); \ No newline at end of file +verify.rangesAreOccurrences(); diff --git a/tests/cases/fourslash/getOccurrencesPrivate1.ts b/tests/cases/fourslash/getOccurrencesPrivate1.ts index 991ed3ea31c..bb601451507 100644 --- a/tests/cases/fourslash/getOccurrencesPrivate1.ts +++ b/tests/cases/fourslash/getOccurrencesPrivate1.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesPrivate2.ts b/tests/cases/fourslash/getOccurrencesPrivate2.ts index 19397443af5..914db1a15a9 100644 --- a/tests/cases/fourslash/getOccurrencesPrivate2.ts +++ b/tests/cases/fourslash/getOccurrencesPrivate2.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts b/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts index 87ec260601b..3a9078cfc63 100644 --- a/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts +++ b/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts @@ -15,11 +15,5 @@ ////} //// ////(new C()).[|abc|]; -test.ranges().forEach(r => { - goTo.position(r.start); - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range); - }); - verify.occurrencesAtPositionCount(test.ranges().length); -}); \ No newline at end of file +verify.rangesAreOccurrences(); diff --git a/tests/cases/fourslash/getOccurrencesProtected1.ts b/tests/cases/fourslash/getOccurrencesProtected1.ts index af9e3302968..b5b3442ec00 100644 --- a/tests/cases/fourslash/getOccurrencesProtected1.ts +++ b/tests/cases/fourslash/getOccurrencesProtected1.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesProtected2.ts b/tests/cases/fourslash/getOccurrencesProtected2.ts index 666736eee16..365d78dc9f6 100644 --- a/tests/cases/fourslash/getOccurrencesProtected2.ts +++ b/tests/cases/fourslash/getOccurrencesProtected2.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesPublic1.ts b/tests/cases/fourslash/getOccurrencesPublic1.ts index a451a70c1cb..1ecc816dac5 100644 --- a/tests/cases/fourslash/getOccurrencesPublic1.ts +++ b/tests/cases/fourslash/getOccurrencesPublic1.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesPublic2.ts b/tests/cases/fourslash/getOccurrencesPublic2.ts index b4887e18e80..6d5b4e53c0e 100644 --- a/tests/cases/fourslash/getOccurrencesPublic2.ts +++ b/tests/cases/fourslash/getOccurrencesPublic2.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesReturn.ts b/tests/cases/fourslash/getOccurrencesReturn.ts index 613e1645fb5..44b3679ba2e 100644 --- a/tests/cases/fourslash/getOccurrencesReturn.ts +++ b/tests/cases/fourslash/getOccurrencesReturn.ts @@ -19,15 +19,9 @@ //// [|return|] true; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesReturn2.ts b/tests/cases/fourslash/getOccurrencesReturn2.ts index 15a062433fe..750648838a2 100644 --- a/tests/cases/fourslash/getOccurrencesReturn2.ts +++ b/tests/cases/fourslash/getOccurrencesReturn2.ts @@ -19,15 +19,9 @@ //// return true; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesReturn3.ts b/tests/cases/fourslash/getOccurrencesReturn3.ts index 030d700ef6e..ee739efef39 100644 --- a/tests/cases/fourslash/getOccurrencesReturn3.ts +++ b/tests/cases/fourslash/getOccurrencesReturn3.ts @@ -19,10 +19,4 @@ //// return true; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); \ No newline at end of file +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesReturnBroken.ts b/tests/cases/fourslash/getOccurrencesReturnBroken.ts index 2327a62d12c..c8d7fad0635 100644 --- a/tests/cases/fourslash/getOccurrencesReturnBroken.ts +++ b/tests/cases/fourslash/getOccurrencesReturnBroken.ts @@ -26,17 +26,11 @@ //// r/*4*/eturn 8675309; ////} -// Note: For this test, these 'return's get highlighted as a result of a parse recovery +// Note: For this test, these 'return's get highlighted as a result of a parse recovery // where if an arrow function starts with a statement, we try to parse a body // as if it was missing curly braces. If the behavior changes in the future, // a change to this test is very much welcome. -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); for (var i = 1; i <= test.markers().length; i++) { goTo.marker("" + i); diff --git a/tests/cases/fourslash/getOccurrencesSetAndGet.ts b/tests/cases/fourslash/getOccurrencesSetAndGet.ts index ddeaf8f26ff..2d28328800c 100644 --- a/tests/cases/fourslash/getOccurrencesSetAndGet.ts +++ b/tests/cases/fourslash/getOccurrencesSetAndGet.ts @@ -23,12 +23,4 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesSetAndGet2.ts b/tests/cases/fourslash/getOccurrencesSetAndGet2.ts index 3e05f511efc..541efc80509 100644 --- a/tests/cases/fourslash/getOccurrencesSetAndGet2.ts +++ b/tests/cases/fourslash/getOccurrencesSetAndGet2.ts @@ -23,12 +23,4 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesSetAndGet3.ts b/tests/cases/fourslash/getOccurrencesSetAndGet3.ts index 777a62db6a5..32c4d72c1a5 100644 --- a/tests/cases/fourslash/getOccurrencesSetAndGet3.ts +++ b/tests/cases/fourslash/getOccurrencesSetAndGet3.ts @@ -23,12 +23,4 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesStatic1.ts b/tests/cases/fourslash/getOccurrencesStatic1.ts index 8be9862d5ec..d853f16017d 100644 --- a/tests/cases/fourslash/getOccurrencesStatic1.ts +++ b/tests/cases/fourslash/getOccurrencesStatic1.ts @@ -54,11 +54,4 @@ //// declare function foo(): string; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts b/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts index 56af87497d5..a115ee82211 100644 --- a/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts +++ b/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts @@ -3,11 +3,4 @@ ////function foo(a: "[|option 1|]") { } ////foo("[|option 1|]"); -const ranges = test.ranges(); -for (let r of ranges) { - goTo.position(r.start); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, false); - } -} +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesStringLiterals.ts b/tests/cases/fourslash/getOccurrencesStringLiterals.ts index 827828acd24..cf17481e0eb 100644 --- a/tests/cases/fourslash/getOccurrencesStringLiterals.ts +++ b/tests/cases/fourslash/getOccurrencesStringLiterals.ts @@ -3,8 +3,4 @@ ////var x = "[|string|]"; ////function f(a = "[|initial value|]") { } -const ranges = test.ranges(); -for (let r of ranges) { - goTo.position(r.start); - verify.occurrencesAtPositionCount(1); -} +goTo.eachRange(() => verify.occurrencesAtPositionCount(1)); diff --git a/tests/cases/fourslash/getOccurrencesSuper.ts b/tests/cases/fourslash/getOccurrencesSuper.ts index f53d9aca62e..6f5c51715f3 100644 --- a/tests/cases/fourslash/getOccurrencesSuper.ts +++ b/tests/cases/fourslash/getOccurrencesSuper.ts @@ -27,7 +27,7 @@ //// //// public method3() { //// var x = () => [|super|].superMethod(); -//// +//// //// // Bad but still gets highlighted //// function f() { //// [|super|].superMethod(); @@ -50,15 +50,9 @@ //// static super = 20; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesSuper2.ts b/tests/cases/fourslash/getOccurrencesSuper2.ts index 1392170ae18..2da702acbc6 100644 --- a/tests/cases/fourslash/getOccurrencesSuper2.ts +++ b/tests/cases/fourslash/getOccurrencesSuper2.ts @@ -27,7 +27,7 @@ //// //// public method3() { //// var x = () => super.superMethod(); -//// +//// //// // Bad but still gets highlighted //// function f() { //// super.superMethod(); @@ -50,15 +50,9 @@ //// static super = 20; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesSuper3.ts b/tests/cases/fourslash/getOccurrencesSuper3.ts index bceac02a392..88275975004 100644 --- a/tests/cases/fourslash/getOccurrencesSuper3.ts +++ b/tests/cases/fourslash/getOccurrencesSuper3.ts @@ -14,7 +14,7 @@ ////} function checkRange(r: FourSlashInterface.Range, expectedOccurences: FourSlashInterface.Range[]): void { - goTo.position(r.start); + goTo.rangeStart(r); if (expectedOccurences.length) { for (const expected of expectedOccurences) { verify.occurrencesAtPositionContains(expected); diff --git a/tests/cases/fourslash/getOccurrencesSuperNegatives.ts b/tests/cases/fourslash/getOccurrencesSuperNegatives.ts index 8c76da33c12..e2bb248efc4 100644 --- a/tests/cases/fourslash/getOccurrencesSuperNegatives.ts +++ b/tests/cases/fourslash/getOccurrencesSuperNegatives.ts @@ -20,8 +20,4 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - verify.occurrencesAtPositionCount(0); -}); +goTo.eachRange(() => verify.occurrencesAtPositionCount(0)); diff --git a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault.ts b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault.ts index f32ff0e8f82..34f9ebcd112 100644 --- a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault.ts +++ b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault.ts @@ -18,12 +18,4 @@ //// [|case|] 16: ////} - -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault2.ts b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault2.ts index dd4577faa1f..1f265f079f8 100644 --- a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault2.ts +++ b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault2.ts @@ -18,12 +18,4 @@ //// case 16: ////} - -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault3.ts b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault3.ts index 24330ca1912..887e17c2b29 100644 --- a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault3.ts +++ b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault3.ts @@ -16,11 +16,4 @@ //// [|break|]; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault4.ts b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault4.ts index 039009746dd..38b3fbfc7dd 100644 --- a/tests/cases/fourslash/getOccurrencesSwitchCaseDefault4.ts +++ b/tests/cases/fourslash/getOccurrencesSwitchCaseDefault4.ts @@ -10,16 +10,5 @@ //// contin/*2*/ue foo; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - verify.occurrencesAtPositionCount(test.ranges().length); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); - -test.markers().forEach(m => { - goTo.position(m.position); - verify.occurrencesAtPositionCount(0); -}); \ No newline at end of file +verify.rangesAreOccurrences(false); +goTo.eachMarker(() => verify.occurrencesAtPositionCount(0)); diff --git a/tests/cases/fourslash/getOccurrencesThis.ts b/tests/cases/fourslash/getOccurrencesThis.ts index e4b059b9cf9..156fde2c4ac 100644 --- a/tests/cases/fourslash/getOccurrencesThis.ts +++ b/tests/cases/fourslash/getOccurrencesThis.ts @@ -89,7 +89,7 @@ //// } //// //// public static staticB = this.staticMethod1; -//// +//// //// public static staticMethod1() { //// this; //// this; @@ -140,15 +140,9 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesThis2.ts b/tests/cases/fourslash/getOccurrencesThis2.ts index 3df30369e3e..9a40eb39fb0 100644 --- a/tests/cases/fourslash/getOccurrencesThis2.ts +++ b/tests/cases/fourslash/getOccurrencesThis2.ts @@ -89,7 +89,7 @@ //// } //// //// public static staticB = this.staticMethod1; -//// +//// //// public static staticMethod1() { //// this; //// this; @@ -140,15 +140,9 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesThis3.ts b/tests/cases/fourslash/getOccurrencesThis3.ts index 7ee18a31286..66c80241e4a 100644 --- a/tests/cases/fourslash/getOccurrencesThis3.ts +++ b/tests/cases/fourslash/getOccurrencesThis3.ts @@ -89,7 +89,7 @@ //// } //// //// public static staticB = this.staticMethod1; -//// +//// //// public static staticMethod1() { //// this; //// this; @@ -140,15 +140,9 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesThis4.ts b/tests/cases/fourslash/getOccurrencesThis4.ts index 75a9383f88e..42ddd7984a8 100644 --- a/tests/cases/fourslash/getOccurrencesThis4.ts +++ b/tests/cases/fourslash/getOccurrencesThis4.ts @@ -89,7 +89,7 @@ //// } //// //// public static staticB = this.staticMethod1; -//// +//// //// public static staticMethod1() { //// this; //// this; @@ -140,15 +140,9 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesThis5.ts b/tests/cases/fourslash/getOccurrencesThis5.ts index 86ce16b16be..845e8342fa5 100644 --- a/tests/cases/fourslash/getOccurrencesThis5.ts +++ b/tests/cases/fourslash/getOccurrencesThis5.ts @@ -89,7 +89,7 @@ //// } //// //// public static staticB = [|this|].staticMethod1; -//// +//// //// public static staticMethod1() { //// [|this|]; //// [|this|]; @@ -140,15 +140,9 @@ //// } ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); \ No newline at end of file +} diff --git a/tests/cases/fourslash/getOccurrencesThisNegatives2.ts b/tests/cases/fourslash/getOccurrencesThisNegatives2.ts index 0a8b5860feb..3f840e8311a 100644 --- a/tests/cases/fourslash/getOccurrencesThisNegatives2.ts +++ b/tests/cases/fourslash/getOccurrencesThisNegatives2.ts @@ -89,7 +89,7 @@ //// } //// //// public static staticB = this.staticMethod1; -//// +//// //// public static staticMethod1() { //// this; //// this; @@ -140,8 +140,4 @@ //// } ////} - -test.markers().forEach(m => { - goTo.position(m.position, m.fileName) - verify.occurrencesAtPositionCount(0); -}); +goTo.eachMarker(() => verify.occurrencesAtPositionCount(0)); diff --git a/tests/cases/fourslash/getOccurrencesThrow.ts b/tests/cases/fourslash/getOccurrencesThrow.ts index 19f10dbfb9f..db80e3c51a0 100644 --- a/tests/cases/fourslash/getOccurrencesThrow.ts +++ b/tests/cases/fourslash/getOccurrencesThrow.ts @@ -3,7 +3,7 @@ ////function f(a: number) { //// try { //// throw "Hello"; -//// +//// //// try { //// throw 10; //// } @@ -42,17 +42,9 @@ //// [|throw|] false; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); +} diff --git a/tests/cases/fourslash/getOccurrencesThrow2.ts b/tests/cases/fourslash/getOccurrencesThrow2.ts index 9bd2f82e638..21425990e2f 100644 --- a/tests/cases/fourslash/getOccurrencesThrow2.ts +++ b/tests/cases/fourslash/getOccurrencesThrow2.ts @@ -3,7 +3,7 @@ ////function f(a: number) { //// try { //// throw "Hello"; -//// +//// //// try { //// [|t/**/hrow|] 10; //// } @@ -42,17 +42,9 @@ //// throw false; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); +} diff --git a/tests/cases/fourslash/getOccurrencesThrow3.ts b/tests/cases/fourslash/getOccurrencesThrow3.ts index 359b783df07..d601123f7bd 100644 --- a/tests/cases/fourslash/getOccurrencesThrow3.ts +++ b/tests/cases/fourslash/getOccurrencesThrow3.ts @@ -3,7 +3,7 @@ ////function f(a: number) { //// try { //// [|throw|] "Hello"; -//// +//// //// try { //// throw 10; //// } @@ -42,17 +42,9 @@ //// throw false; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); +} diff --git a/tests/cases/fourslash/getOccurrencesThrow4.ts b/tests/cases/fourslash/getOccurrencesThrow4.ts index ab2375907ee..c348685b4ed 100644 --- a/tests/cases/fourslash/getOccurrencesThrow4.ts +++ b/tests/cases/fourslash/getOccurrencesThrow4.ts @@ -3,7 +3,7 @@ ////function f(a: number) { //// try { //// throw "Hello"; -//// +//// //// try { //// throw 10; //// } @@ -42,17 +42,9 @@ //// throw false; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); +} diff --git a/tests/cases/fourslash/getOccurrencesThrow5.ts b/tests/cases/fourslash/getOccurrencesThrow5.ts index 9ba28191752..b4b51b677bc 100644 --- a/tests/cases/fourslash/getOccurrencesThrow5.ts +++ b/tests/cases/fourslash/getOccurrencesThrow5.ts @@ -3,7 +3,7 @@ ////function f(a: number) { //// try { //// throw "Hello"; -//// +//// //// try { //// throw 10; //// } @@ -42,17 +42,9 @@ //// throw false; ////} -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +verify.rangesAreOccurrences(false); goTo.marker(); -test.ranges().forEach(range => { +for (const range of test.ranges()) { verify.occurrencesAtPositionContains(range, false); -}); +} diff --git a/tests/cases/fourslash/getOccurrencesThrow6.ts b/tests/cases/fourslash/getOccurrencesThrow6.ts index 8b58347ed8a..21509659cd8 100644 --- a/tests/cases/fourslash/getOccurrencesThrow6.ts +++ b/tests/cases/fourslash/getOccurrencesThrow6.ts @@ -14,15 +14,4 @@ //// [|throw|] 300; ////} - - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesThrow7.ts b/tests/cases/fourslash/getOccurrencesThrow7.ts index 48ab981d762..7a35daeb775 100644 --- a/tests/cases/fourslash/getOccurrencesThrow7.ts +++ b/tests/cases/fourslash/getOccurrencesThrow7.ts @@ -19,13 +19,4 @@ //// ////[|throw|] 10; -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/getOccurrencesThrow8.ts b/tests/cases/fourslash/getOccurrencesThrow8.ts index cc527720dc4..0e57520d492 100644 --- a/tests/cases/fourslash/getOccurrencesThrow8.ts +++ b/tests/cases/fourslash/getOccurrencesThrow8.ts @@ -19,13 +19,4 @@ //// ////throw 10; -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/quickInfoInvalidLocations.ts b/tests/cases/fourslash/quickInfoInvalidLocations.ts index 81845e27672..c70be23f387 100644 --- a/tests/cases/fourslash/quickInfoInvalidLocations.ts +++ b/tests/cases/fourslash/quickInfoInvalidLocations.ts @@ -27,13 +27,13 @@ //// ////mod/*invlaid10*/ule m1 { //// va/*invlaid11*/r varibale = 0; -//// +//// //// func/*invlaid12*/tion foo(arg1: number) { //// ret/*invlaid13*/urn string; //// } //// //// class foo { -//// +//// //// } //// //// var object = { @@ -44,9 +44,5 @@ //// }; ////} - -test.markers().forEach((marker) => { - goTo.position(marker.position, marker.fileName); - verify.not.quickInfoExists(); -}); +goTo.eachMarker(() => verify.not.quickInfoExists()); diff --git a/tests/cases/fourslash/referencesForIndexProperty2.ts b/tests/cases/fourslash/referencesForIndexProperty2.ts index 0aa099c9622..35c9d7cdd64 100644 --- a/tests/cases/fourslash/referencesForIndexProperty2.ts +++ b/tests/cases/fourslash/referencesForIndexProperty2.ts @@ -5,6 +5,4 @@ ////var a; ////a["[|blah|]"]; -goTo.position(test.ranges()[0].start, test.ranges()[0].fileName); -verify.referencesAre(test.ranges()); - +verify.rangesReferenceEachOther(); diff --git a/tests/cases/fourslash/referencesInComment.ts b/tests/cases/fourslash/referencesInComment.ts index c53a2e6d9b3..eabf74d2f23 100644 --- a/tests/cases/fourslash/referencesInComment.ts +++ b/tests/cases/fourslash/referencesInComment.ts @@ -5,6 +5,4 @@ ////class foo { } ////var bar = 0; -for (const marker of test.markers()) { - verify.referencesAre([]); -} +goTo.eachMarker(() => verify.referencesAre([])); diff --git a/tests/cases/fourslash/renameAlias.ts b/tests/cases/fourslash/renameAlias.ts index e0408af656f..3869b1522b5 100644 --- a/tests/cases/fourslash/renameAlias.ts +++ b/tests/cases/fourslash/renameAlias.ts @@ -4,8 +4,4 @@ ////import [|M|] = SomeModule; ////import C = [|M|].SomeClass; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameAlias2.ts b/tests/cases/fourslash/renameAlias2.ts index da1bcf8248d..f97121f5f7d 100644 --- a/tests/cases/fourslash/renameAlias2.ts +++ b/tests/cases/fourslash/renameAlias2.ts @@ -4,8 +4,4 @@ ////import M = [|SomeModule|]; ////import C = M.SomeClass; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); \ No newline at end of file diff --git a/tests/cases/fourslash/renameAlias3.ts b/tests/cases/fourslash/renameAlias3.ts index 9172f052abb..af3bafef115 100644 --- a/tests/cases/fourslash/renameAlias3.ts +++ b/tests/cases/fourslash/renameAlias3.ts @@ -4,8 +4,4 @@ ////import M = SomeModule; ////import C = M.[|SomeClass|]; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameAliasExternalModule.ts b/tests/cases/fourslash/renameAliasExternalModule.ts index 54277fd6e64..49cc6396717 100644 --- a/tests/cases/fourslash/renameAliasExternalModule.ts +++ b/tests/cases/fourslash/renameAliasExternalModule.ts @@ -8,9 +8,4 @@ ////import [|M|] = require("./a"); ////import C = [|M|].SomeClass; -let ranges = test.ranges() -for (let range of ranges) { - goTo.file(range.fileName); - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameAliasExternalModule2.ts b/tests/cases/fourslash/renameAliasExternalModule2.ts index 2d9d07efb68..35916295a8e 100644 --- a/tests/cases/fourslash/renameAliasExternalModule2.ts +++ b/tests/cases/fourslash/renameAliasExternalModule2.ts @@ -8,9 +8,4 @@ ////import M = require("./a"); ////import C = M.SomeClass; -let ranges = test.ranges() -for (let range of ranges) { - goTo.file(range.fileName); - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameAliasExternalModule3.ts b/tests/cases/fourslash/renameAliasExternalModule3.ts index acff9371c77..53b28e7983e 100644 --- a/tests/cases/fourslash/renameAliasExternalModule3.ts +++ b/tests/cases/fourslash/renameAliasExternalModule3.ts @@ -8,9 +8,4 @@ ////import M = require("./a"); ////import C = M.[|SomeClass|]; -let ranges = test.ranges() -for (let range of ranges) { - goTo.file(range.fileName); - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameContextuallyTypedProperties.ts b/tests/cases/fourslash/renameContextuallyTypedProperties.ts index 4feed49256f..4ce3c2b0738 100644 --- a/tests/cases/fourslash/renameContextuallyTypedProperties.ts +++ b/tests/cases/fourslash/renameContextuallyTypedProperties.ts @@ -55,9 +55,4 @@ //// set ["prop2"](v) { } ////}; -let ranges = test.ranges() -for (let range of ranges) { - goTo.file(range.fileName); - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameContextuallyTypedProperties2.ts b/tests/cases/fourslash/renameContextuallyTypedProperties2.ts index 1887c7751a5..01e638395a0 100644 --- a/tests/cases/fourslash/renameContextuallyTypedProperties2.ts +++ b/tests/cases/fourslash/renameContextuallyTypedProperties2.ts @@ -55,9 +55,4 @@ //// set ["[|prop2|]"](v) { } ////}; -let ranges = test.ranges() -for (let range of ranges) { - goTo.file(range.fileName); - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDefaultImport.ts b/tests/cases/fourslash/renameDefaultImport.ts index fd9534e65f7..8d9b65d78d6 100644 --- a/tests/cases/fourslash/renameDefaultImport.ts +++ b/tests/cases/fourslash/renameDefaultImport.ts @@ -1,19 +1,14 @@ /// -// @Filename: B.ts -////export default class [|B|] { -//// test() { -//// } -////} +// @Filename: B.ts +////export default class [|B|] { +//// test() { +//// } +////} -// @Filename: A.ts -////import [|B|] from "./B"; -////let b = new [|B|](); +// @Filename: A.ts +////import [|B|] from "./B"; +////let b = new [|B|](); ////b.test(); -let ranges = test.ranges() -for (let range of ranges) { - goTo.file(range.fileName); - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDefaultImportDifferentName.ts b/tests/cases/fourslash/renameDefaultImportDifferentName.ts index 5965f1a63e9..aec699aadda 100644 --- a/tests/cases/fourslash/renameDefaultImportDifferentName.ts +++ b/tests/cases/fourslash/renameDefaultImportDifferentName.ts @@ -1,23 +1,17 @@ /// -// @Filename: B.ts -////export default class /*1*/C { -//// test() { -//// } -////} +// @Filename: B.ts +////export default class /*1*/C { +//// test() { +//// } +////} -// @Filename: A.ts -////import [|B|] from "./B"; -////let b = new [|B|](); +// @Filename: A.ts +////import [|B|] from "./B"; +////let b = new [|B|](); ////b.test(); -goTo.file("B.ts"); goTo.marker("1"); verify.occurrencesAtPositionCount(1); -goTo.file("A.ts"); -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringAssignment.ts b/tests/cases/fourslash/renameDestructuringAssignment.ts index b7b18f661d2..89a44a3a9d9 100644 --- a/tests/cases/fourslash/renameDestructuringAssignment.ts +++ b/tests/cases/fourslash/renameDestructuringAssignment.ts @@ -1,14 +1,10 @@ /// -////interface I { -//// [|x|]: number; -////} -////var a: I; -////var x; +////interface I { +//// [|x|]: number; +////} +////var a: I; +////var x; ////({ [|x|]: x } = a); -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentInFor2.ts b/tests/cases/fourslash/renameDestructuringAssignmentInFor2.ts index ca75e42394b..4d79b47a267 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentInFor2.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentInFor2.ts @@ -1,20 +1,16 @@ /// -////interface I { -//// property1: number; -//// property2: string; -////} -////var elems: I[]; -//// -////var p2: number, [|property1|]: number; -////for ({ [|property1|] } = elems[0]; p2 < 100; p2++) { -//// p2 = [|property1|]++; +////interface I { +//// property1: number; +//// property2: string; ////} -////for ({ property1: p2 } = elems[0]; p2 < 100; p2++) { +////var elems: I[]; +//// +////var p2: number, [|property1|]: number; +////for ({ [|property1|] } = elems[0]; p2 < 100; p2++) { +//// p2 = [|property1|]++; +////} +////for ({ property1: p2 } = elems[0]; p2 < 100; p2++) { ////} -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentInForOf2.ts b/tests/cases/fourslash/renameDestructuringAssignmentInForOf2.ts index 401b6776d2e..9987a17d36e 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentInForOf2.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentInForOf2.ts @@ -1,20 +1,16 @@ /// -////interface I { -//// property1: number; -//// property2: string; -////} -////var elems: I[]; -//// -////var [|property1|]: number, p2: number; -////for ({ [|property1|] } of elems) { -//// [|property1|]++; +////interface I { +//// property1: number; +//// property2: string; ////} -////for ({ property1: p2 } of elems) { +////var elems: I[]; +//// +////var [|property1|]: number, p2: number; +////for ({ [|property1|] } of elems) { +//// [|property1|]++; +////} +////for ({ property1: p2 } of elems) { ////} -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral2.ts b/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral2.ts index c4db2de512f..e45ae3349a4 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral2.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral2.ts @@ -1,15 +1,11 @@ /// -////interface I { -//// property1: number; -//// property2: string; -////} -////var elems: I[], p1: number, [|property1|]: number; -////[{ property1: p1 }] = elems; -////[{ [|property1|] }] = elems; +////interface I { +//// property1: number; +//// property2: string; +////} +////var elems: I[], p1: number, [|property1|]: number; +////[{ property1: p1 }] = elems; +////[{ [|property1|] }] = elems; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor2.ts b/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor2.ts index 89dc899c5bf..2ec7d906ad1 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor2.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor2.ts @@ -1,5 +1,5 @@ -/// - +/// + ////interface MultiRobot { //// name: string; //// skills: { @@ -14,10 +14,5 @@ ////for ({ skills: { [|primary|], secondary } } = multiRobot, i = 0; i < 1; i++) { //// console.log([|primary|]); ////} - -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} - + +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts b/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts index b684e6b6a81..5364cffebb9 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts @@ -1,5 +1,5 @@ -/// - +/// + ////interface MultiRobot { //// name: string; //// skills: { @@ -14,10 +14,6 @@ ////for ({ skills: { [|primary|], secondary } } of multiRobots) { //// console.log([|primary|]); ////} - - -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} + + +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringClassProperty.ts b/tests/cases/fourslash/renameDestructuringClassProperty.ts index acc58f999c4..11261a4df78 100644 --- a/tests/cases/fourslash/renameDestructuringClassProperty.ts +++ b/tests/cases/fourslash/renameDestructuringClassProperty.ts @@ -1,5 +1,5 @@ -/// - +/// + ////class A { //// [|foo|]: string; ////} @@ -14,10 +14,6 @@ //// let { [|foo|] } = a; //// [|foo|] = "newString"; //// } -////} - -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +////} + +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts b/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts index 0edf9085092..0338433ae72 100644 --- a/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts +++ b/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts @@ -1,20 +1,16 @@ /// -////interface I { -//// [|property1|]: number; -//// property2: string; -////} -////var elems: I[]; -//// -////var p2: number, property1: number; -////for (let { [|property1|]: p2 } = elems[0]; p2 < 100; p2++) { +////interface I { +//// [|property1|]: number; +//// property2: string; ////} -////for (let { [|property1|] } = elems[0]; p2 < 100; p2++) { -//// [|property1|] = p2; +////var elems: I[]; +//// +////var p2: number, property1: number; +////for (let { [|property1|]: p2 } = elems[0]; p2 < 100; p2++) { +////} +////for (let { [|property1|] } = elems[0]; p2 < 100; p2++) { +//// [|property1|] = p2; ////} -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringDeclarationInForOf.ts b/tests/cases/fourslash/renameDestructuringDeclarationInForOf.ts index 1c2b04b7ab5..fcd55a5bc20 100644 --- a/tests/cases/fourslash/renameDestructuringDeclarationInForOf.ts +++ b/tests/cases/fourslash/renameDestructuringDeclarationInForOf.ts @@ -1,19 +1,15 @@ /// -////interface I { -//// [|property1|]: number; -//// property2: string; -////} -////var elems: I[]; -//// -////for (let { [|property1|] } of elems) { -//// [|property1|]++; +////interface I { +//// [|property1|]: number; +//// property2: string; ////} -////for (let { [|property1|]: p2 } of elems) { +////var elems: I[]; +//// +////for (let { [|property1|] } of elems) { +//// [|property1|]++; +////} +////for (let { [|property1|]: p2 } of elems) { ////} -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringFunctionParameter.ts b/tests/cases/fourslash/renameDestructuringFunctionParameter.ts index d1df0f58275..4abbabc3723 100644 --- a/tests/cases/fourslash/renameDestructuringFunctionParameter.ts +++ b/tests/cases/fourslash/renameDestructuringFunctionParameter.ts @@ -1,10 +1,7 @@ /// -////function f({[|a|]}: {[|a|]}) { -//// f({[|a|]}); +////function f({[|a|]}: {[|a|]}) { +//// f({[|a|]}); ////} -let ranges = test.ranges(); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} + +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts b/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts index 1c4254b14ae..7557744ecee 100644 --- a/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts +++ b/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts @@ -1,5 +1,5 @@ -/// - +/// + ////interface MultiRobot { //// name: string; //// skills: { @@ -13,10 +13,6 @@ ////} ////for (let { skills: {[|primary|], secondary } } of multiRobots) { //// console.log([|primary|]); -////} - -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +////} + +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameForDefaultExport01.ts b/tests/cases/fourslash/renameForDefaultExport01.ts index 809c127a727..96f0d6e54e8 100644 --- a/tests/cases/fourslash/renameForDefaultExport01.ts +++ b/tests/cases/fourslash/renameForDefaultExport01.ts @@ -10,9 +10,4 @@ //// ////var y = new /*3*/[|DefaultExportedClass|]; -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); -} \ No newline at end of file +goTo.eachMarker(() => verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true)); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport02.ts b/tests/cases/fourslash/renameForDefaultExport02.ts index ddf4b224023..471b10e32b2 100644 --- a/tests/cases/fourslash/renameForDefaultExport02.ts +++ b/tests/cases/fourslash/renameForDefaultExport02.ts @@ -11,9 +11,4 @@ //// ////var y = /*4*/[|DefaultExportedFunction|](); -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); -} \ No newline at end of file +goTo.eachMarker(() => verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true)); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport03.ts b/tests/cases/fourslash/renameForDefaultExport03.ts index 6f82d96fe5e..1da6ff20b0b 100644 --- a/tests/cases/fourslash/renameForDefaultExport03.ts +++ b/tests/cases/fourslash/renameForDefaultExport03.ts @@ -17,9 +17,4 @@ //// var local = 100; ////} -let markers = test.markers() -for (let marker of markers) { - goTo.position(marker.position); - - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true); -} \ No newline at end of file +goTo.eachMarker(() => verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true)); \ No newline at end of file diff --git a/tests/cases/fourslash/renameImportAndExport.ts b/tests/cases/fourslash/renameImportAndExport.ts index 495e15c1e7e..fe8bce4b208 100644 --- a/tests/cases/fourslash/renameImportAndExport.ts +++ b/tests/cases/fourslash/renameImportAndExport.ts @@ -3,8 +3,4 @@ ////import [|a|] from "module"; ////export { [|a|] }; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameImportAndShorthand.ts b/tests/cases/fourslash/renameImportAndShorthand.ts index bc4746aebdd..4836d8c14fe 100644 --- a/tests/cases/fourslash/renameImportAndShorthand.ts +++ b/tests/cases/fourslash/renameImportAndShorthand.ts @@ -3,8 +3,4 @@ ////import [|foo|] from 'bar'; ////const bar = { [|foo|] }; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts b/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts index a6b06c11408..21cdc0fa820 100644 --- a/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts +++ b/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts @@ -3,8 +3,4 @@ ////import * as [|foo|] from 'bar'; ////const bar = { [|foo|] }; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameImportOfExportEquals.ts b/tests/cases/fourslash/renameImportOfExportEquals.ts index 9d71ee907c8..192acefd6fd 100644 --- a/tests/cases/fourslash/renameImportOfExportEquals.ts +++ b/tests/cases/fourslash/renameImportOfExportEquals.ts @@ -11,8 +11,4 @@ //// export { [|N|] }; // Renaming N here would rename ////} -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameImportRequire.ts b/tests/cases/fourslash/renameImportRequire.ts index c26cc80b616..8a9aeebc328 100644 --- a/tests/cases/fourslash/renameImportRequire.ts +++ b/tests/cases/fourslash/renameImportRequire.ts @@ -1,12 +1,8 @@ /// -////import [|e|] = require("mod4"); -////[|e|]; -////a = { [|e|] }; +////import [|e|] = require("mod4"); +////[|e|]; +////a = { [|e|] }; ////export { [|e|] }; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameInheritedProperties1.ts b/tests/cases/fourslash/renameInheritedProperties1.ts index 4698fe3d97b..b42335277a9 100644 --- a/tests/cases/fourslash/renameInheritedProperties1.ts +++ b/tests/cases/fourslash/renameInheritedProperties1.ts @@ -7,9 +7,4 @@ //// var v: class1; //// v.[|propName|]; -const ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (const range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameInheritedProperties2.ts b/tests/cases/fourslash/renameInheritedProperties2.ts index ed99ec3e013..bcc4c5fc323 100644 --- a/tests/cases/fourslash/renameInheritedProperties2.ts +++ b/tests/cases/fourslash/renameInheritedProperties2.ts @@ -7,9 +7,4 @@ //// var v: class1; //// v.[|doStuff|](); -let ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameInheritedProperties3.ts b/tests/cases/fourslash/renameInheritedProperties3.ts index 17e7785fbc7..f1ec547d6ed 100644 --- a/tests/cases/fourslash/renameInheritedProperties3.ts +++ b/tests/cases/fourslash/renameInheritedProperties3.ts @@ -7,9 +7,4 @@ //// var v: interface1; //// v.[|propName|]; -let ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameInheritedProperties4.ts b/tests/cases/fourslash/renameInheritedProperties4.ts index ea2f7c40fbf..42d9acfdb53 100644 --- a/tests/cases/fourslash/renameInheritedProperties4.ts +++ b/tests/cases/fourslash/renameInheritedProperties4.ts @@ -7,9 +7,4 @@ //// var v: interface1; //// v.[|doStuff|](); -let ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameInheritedProperties5.ts b/tests/cases/fourslash/renameInheritedProperties5.ts index 45058827747..e153742d4ed 100644 --- a/tests/cases/fourslash/renameInheritedProperties5.ts +++ b/tests/cases/fourslash/renameInheritedProperties5.ts @@ -9,9 +9,5 @@ //// var d: D; //// d.[|propD|]; -const ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (const range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); + diff --git a/tests/cases/fourslash/renameInheritedProperties6.ts b/tests/cases/fourslash/renameInheritedProperties6.ts index 6bdd32ce3e0..59318334cb0 100644 --- a/tests/cases/fourslash/renameInheritedProperties6.ts +++ b/tests/cases/fourslash/renameInheritedProperties6.ts @@ -9,9 +9,4 @@ //// var d: D; //// d.[|propC|]; -const ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (const range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameInheritedProperties7.ts b/tests/cases/fourslash/renameInheritedProperties7.ts index a2f8c5a2b51..bc0521458f8 100644 --- a/tests/cases/fourslash/renameInheritedProperties7.ts +++ b/tests/cases/fourslash/renameInheritedProperties7.ts @@ -3,17 +3,12 @@ //// class C extends D { //// [|prop1|]: string; //// } -//// +//// //// class D extends C { //// prop1: string; //// } -//// +//// //// var c: C; //// c.[|prop1|]; -const ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (const range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameInheritedProperties8.ts b/tests/cases/fourslash/renameInheritedProperties8.ts index 119e1a477aa..7cde300bf0b 100644 --- a/tests/cases/fourslash/renameInheritedProperties8.ts +++ b/tests/cases/fourslash/renameInheritedProperties8.ts @@ -3,17 +3,12 @@ //// class C implements D { //// [|prop1|]: string; //// } -//// +//// //// interface D extends C { //// [|prop1|]: string; //// } -//// +//// //// var c: C; //// c.[|prop1|]; -const ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (const range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts index b95040085c9..b0f2f509500 100644 --- a/tests/cases/fourslash/renameLocationsForClassExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -11,7 +11,7 @@ //// static doItStatically() { //// return [|Foo|].y; //// } -////} +////} //// ////var y = class { //// getSomeName() { @@ -20,8 +20,4 @@ ////} ////var z = class Foo {} -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts index e884783d960..1e02e3f5284 100644 --- a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts @@ -4,9 +4,4 @@ //// [|f|]([|f|], g); ////} -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts index 8186611cb64..a258bcd803d 100644 --- a/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts @@ -1,7 +1,7 @@ /// ////function f() { -//// +//// ////} ////var x = function [|f|](g: any, h: any) { //// @@ -10,9 +10,4 @@ //// let foo = () => [|f|]([|f|], g); ////} -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts index 535dbd3d5a3..4ae87f19db5 100644 --- a/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts +++ b/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts @@ -8,7 +8,4 @@ ////var foo: I; ////var { [|property1|]: prop1 } = foo; -for (let range of test.ranges()) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameObjectSpread.ts b/tests/cases/fourslash/renameObjectSpread.ts index eba148c0e39..f56c22dd42f 100644 --- a/tests/cases/fourslash/renameObjectSpread.ts +++ b/tests/cases/fourslash/renameObjectSpread.ts @@ -10,11 +10,11 @@ const ranges = test.ranges(); verify.assertHasRanges(ranges); // A1 unions with A2, so rename A1.a and a12.a -goTo.position(ranges[0].start); +goTo.rangeStart(ranges[0]); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[0], ranges[2]]); // A1 unions with A2, so rename A2.a and a12.a -goTo.position(ranges[1].start); +goTo.rangeStart(ranges[1]); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[1], ranges[2]]); // a12.a unions A1.a and A2.a, so rename A1.a, A2.a and a12.a -goTo.position(ranges[2].start); +goTo.rangeStart(ranges[2]); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[0], ranges[1], ranges[2]]); diff --git a/tests/cases/fourslash/renameObjectSpreadAssignment.ts b/tests/cases/fourslash/renameObjectSpreadAssignment.ts index 9cf0b6ebf81..2ddebb6e18b 100644 --- a/tests/cases/fourslash/renameObjectSpreadAssignment.ts +++ b/tests/cases/fourslash/renameObjectSpreadAssignment.ts @@ -5,16 +5,18 @@ ////let [|a1|]: A1; ////let [|a2|]: A2; ////let a12 = { ...[|a1|], ...[|a2|] }; + const ranges = test.ranges(); verify.assertHasRanges(ranges); + // rename a1 -goTo.position(ranges[0].start); +goTo.rangeStart(ranges[0]); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[0], ranges[2]]); -goTo.position(ranges[2].start); +goTo.rangeStart(ranges[2]); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[0], ranges[2]]); // rename a2 -goTo.position(ranges[1].start); +goTo.rangeStart(ranges[1]); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[1], ranges[3]]); -goTo.position(ranges[3].start); +goTo.rangeStart(ranges[3]); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[1], ranges[3]]); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts index 42bfbf63a47..14f8a240bfb 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts @@ -7,9 +7,4 @@ //// } //// } -let ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts index e7ef9d1c1a2..ce31ad6c9c5 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts @@ -7,9 +7,4 @@ //// } //// } -let ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration3.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration3.ts index 9446e2aeb75..6291eff2605 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration3.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration3.ts @@ -7,9 +7,4 @@ //// } //// } -let ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration4.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration4.ts index 7fb4b8c757d..ca201d28b2c 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration4.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration4.ts @@ -6,9 +6,4 @@ //// } //// } -let ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts index b7c47a4c0d7..f989e7c3fd9 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts @@ -6,9 +6,4 @@ //// } //// } -let ranges = test.ranges(); -verify.assertHasRanges(ranges); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameRest.ts b/tests/cases/fourslash/renameRest.ts index a5cc2c38683..60fc1bbb227 100644 --- a/tests/cases/fourslash/renameRest.ts +++ b/tests/cases/fourslash/renameRest.ts @@ -7,9 +7,5 @@ ////let t: Gen; ////var { x, ...rest } = t; ////rest.[|parent|]; -const ranges = test.ranges(); -verify.assertHasRanges(ranges); -goTo.position(ranges[0].start); -verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, ranges); -goTo.position(ranges[1].start); -verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, ranges); + +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameStingPropertyNames.ts b/tests/cases/fourslash/renameStingPropertyNames.ts index a948220efad..13863b043e7 100644 --- a/tests/cases/fourslash/renameStingPropertyNames.ts +++ b/tests/cases/fourslash/renameStingPropertyNames.ts @@ -12,9 +12,4 @@ ////o['[|prop|]']; ////o.[|prop|]; - -let ranges = test.ranges(); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameStringLiteralTypes.ts b/tests/cases/fourslash/renameStringLiteralTypes.ts index f9df83371c1..d0e7368f25d 100644 --- a/tests/cases/fourslash/renameStringLiteralTypes.ts +++ b/tests/cases/fourslash/renameStringLiteralTypes.ts @@ -11,8 +11,4 @@ //// ////animate({ deltaX: 100, deltaY: 100, easing: "[|ease-in-out|]" }); -let ranges = test.ranges(); -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/renameThis.ts b/tests/cases/fourslash/renameThis.ts index f567cace70d..c4e5d932261 100644 --- a/tests/cases/fourslash/renameThis.ts +++ b/tests/cases/fourslash/renameThis.ts @@ -8,7 +8,7 @@ let [r0, r1, r2, r3] = test.ranges() for (let range of [r0, r1]) { - goTo.position(range.start); + goTo.rangeStart(range); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [r0, r1]); } @@ -17,6 +17,6 @@ goTo.marker(); verify.renameInfoFailed("You cannot rename this element."); for (let range of [r2, r3]) { - goTo.position(range.start); + goTo.rangeStart(range); verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [r2, r3]); } diff --git a/tests/cases/fourslash/renameUMDModuleAlias1.ts b/tests/cases/fourslash/renameUMDModuleAlias1.ts index 94aabcdbde5..c44e459b008 100644 --- a/tests/cases/fourslash/renameUMDModuleAlias1.ts +++ b/tests/cases/fourslash/renameUMDModuleAlias1.ts @@ -10,8 +10,4 @@ //// /// //// [|myLib|].doThing(); -const ranges = test.ranges() -for (const range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -} \ No newline at end of file +verify.rangesAreRenameLocations(); diff --git a/tests/cases/fourslash/server/occurrences01.ts b/tests/cases/fourslash/server/occurrences01.ts index db2fa64f38d..f6e39d55b91 100644 --- a/tests/cases/fourslash/server/occurrences01.ts +++ b/tests/cases/fourslash/server/occurrences01.ts @@ -10,13 +10,4 @@ //// continue foo; ////} -let ranges = test.ranges(); - -for (let r of ranges) { - goTo.position(r.start); - verify.occurrencesAtPositionCount(ranges.length); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range, /*isWriteAccess*/ false); - } -} \ No newline at end of file +verify.rangesAreOccurrences(false); diff --git a/tests/cases/fourslash/server/occurrences02.ts b/tests/cases/fourslash/server/occurrences02.ts index e0d39cb92fd..4cf8f1bcac3 100644 --- a/tests/cases/fourslash/server/occurrences02.ts +++ b/tests/cases/fourslash/server/occurrences02.ts @@ -4,13 +4,4 @@ //// [|f|]([|f|]); ////} -let ranges = test.ranges(); - -for (let r of ranges) { - goTo.position(r.start); - verify.occurrencesAtPositionCount(ranges.length); - - for (let range of ranges) { - verify.occurrencesAtPositionContains(range); - } -} \ No newline at end of file +verify.rangesAreOccurrences(); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts index 39644ba8c24..87c9262f893 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f `/*1*/ qwe/*2*/rty /*3*/$/*4*/{ 123 }/*5*/ as/*6*/df /*7*/$/*8*/{ 41234 }/*9*/ zxc/*10*/vb /*11*/$/*12*/{ g ` ` }/*13*/ /*14*/ /*15*/` -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts index 123a6cc4c2c..ef306a22934 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f `/*1*/ qwe/*2*/rty /*3*/$/*4*/{ 123 }/*5*/ as/*6*/df /*7*/$/*8*/{ 41234 }/*9*/ zxc/*10*/vb /*11*/$/*12*/{ g ` ` }/*13*/ /*14*/ /*15*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts index f203468ca04..7859fd6f457 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` qwerty ${/*1*/ /*2*/123/*3*/ /*4*/} asdf ${ 41234 } zxcvb ${ g ` ` } ` -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts index 13ee47a3309..4c8ce2cd917 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` qwerty ${ 123 } asdf ${/*1*/ /*2*/ /*3*/41/*4*/234/*5*/ /*6*/} zxcvb ${ g ` ` } ` -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts index 7cd2affd675..03ef244e719 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${/*1*/ /*2*/g/*3*/ /*4*/` `/*5*/ /*6*/} ` -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts index 7671666bb54..67ab1199be8 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${ g `/*1*/ /*2*/ /*3*/` } ` -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(1); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts index 35bed336f39..cd17ddd1027 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f `/*1*/ /*2*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(1); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts index 1da96ea5c1b..2995c6cdcd8 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// -//// f `/*1*/ /*2*/${ - -test.markers().forEach(m => { - goTo.position(m.position); +//// +//// f `/*1*/ /*2*/${ +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(2); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts index 68ff7202f01..d1ceebfb1b0 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` ${/*1*/ /*2*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(2); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts index 8165da7f67b..211fa66f594 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` ${ }/*1*/ /*2*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(2); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts index 8c970b60c77..79432077ce9 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` ${ } ${/*1*/ /*2*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts index f93da36ce5c..18ffdbe3bf0 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` ${ } ${ }/*1*/ /*2*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts index 10d81eb80f4..fdd6f22554d 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` ${ 123 } ${/*1*/ } ` -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete7.ts index a8afe2d9c6d..9bc4a535564 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete7.ts @@ -2,15 +2,13 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f ` ${ 123 } /*1*/${ } /*2*/\/*3*/ //// /*4*/\\/*5*/ //// /*6*/\\\/*7*/ //// /*8*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts index 86455a65ccd..05ab05c3e6c 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f `/*1*/\/*2*/`/*3*/ /*4*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(1); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete9.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete9.ts index de42a33b397..597ec928bb9 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete9.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete9.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f `/*1*/ \\\/*2*/`/*3*/ /*4*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(1); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives1.ts index c61f1a871e4..10f9f81fa61 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives1.ts @@ -2,10 +2,7 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// /*1*/f/*2*/ /*3*/` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${ g ` ` } `/*4*/ -test.markers().forEach(m => { - goTo.position(m.position); - verify.not.signatureHelpPresent(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.not.signatureHelpPresent()); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives2.ts index e7a5078dcd0..da21fda631c 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives2.ts @@ -2,10 +2,7 @@ //// function foo(strs, ...rest) { //// } -//// +//// //// /*1*/fo/*2*/o /*3*/`abcd${0 + 1}abcd{1 + 1}`/*4*/ /*5*/ -test.markers().forEach(m => { - goTo.position(m.position); - verify.not.signatureHelpPresent(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.not.signatureHelpPresent()); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives3.ts index c84b92fee4f..9ccbe927a57 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives3.ts @@ -2,10 +2,7 @@ //// function foo(strs, ...rest) { //// } -//// +//// //// /*1*/fo/*2*/o /*3*/`abcd${0 + 1}abcd{1 + 1}abcd`/*4*/ /*5*/ -test.markers().forEach(m => { - goTo.position(m.position); - verify.not.signatureHelpPresent(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.not.signatureHelpPresent()); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives4.ts index 338a8dc65ca..825afd265ab 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives4.ts @@ -2,10 +2,7 @@ //// function foo(strs, ...rest) { //// } -//// +//// //// /*1*/fo/*2*/o /*3*/``/*4*/ /*5*/ -test.markers().forEach(m => { - goTo.position(m.position); - verify.not.signatureHelpPresent(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.not.signatureHelpPresent()); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives5.ts index 02383df9267..5b14b627f6a 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives5.ts @@ -2,10 +2,7 @@ //// function foo(strs, ...rest) { //// } -//// +//// //// /*1*/fo/*2*/o /*3*/`abcd`/*4*/ -test.markers().forEach(m => { - goTo.position(m.position); - verify.not.signatureHelpPresent(); -}); \ No newline at end of file +goTo.eachMarker(() => verify.not.signatureHelpPresent()); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts index a3c9f7ccce4..313e55bf517 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f `a ${ g `/*1*/alpha/*2*/ ${/*3*/ 12/*4*/3 /*5*/} beta /*6*/${ /*7*/456 /*8*/} gamma/*9*/` } b ${ g `/*10*/txt/*11*/` } c ${ g `/*12*/aleph /*13*/$/*14*/{ 12/*15*/3 } beit/*16*/` } d`; -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.currentSignatureParameterCountIs(4); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts index d72fa74d985..aa04e425998 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts @@ -2,12 +2,10 @@ //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } -//// +//// //// f `/*1*/a $/*2*/{ /*3*/g /*4*/`alpha ${ 123 } beta ${ 456 } gamma`/*5*/ }/*6*/ b $/*7*/{ /*8*/g /*9*/`txt`/*10*/ } /*11*/c ${ /*12*/g /*13*/`aleph ${ 123 } beit`/*14*/ } d/*15*/`; -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(1); verify.currentSignatureParameterCountIs(4); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts index 6850b1bc54f..54aee5887b8 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// +//// //// f `/*1*/ /*2*/$/*3*/{ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(2); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts index 8466c6b05f2..9cbd20a49d2 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// +//// //// f `${/*1*/ /*2*/ /*3*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(2); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts index b919afc7703..a9b91dbf438 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: TemplateStringsArray, p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: TemplateStringsArray, p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// +//// //// f `${/*1*/ "s/*2*/tring" /*3*/ } ${ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts index a1072366a98..96ff7c4683a 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// +//// //// f `${/*1*/ 123.456/*2*/ /*3*/ } ${ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts index 2646e70b39c..52a1e3f74be 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// +//// //// f `${ } ${/*1*/ /*2*/ /*3*/ -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts index 62410a5fda3..b34df14e926 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// +//// //// f `${ } ${/*1*/ /*2*/ /*3*/} -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts index 5f706b8c0fa..26a80e36f6f 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: TemplateStringsArray, p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: TemplateStringsArray, p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// +//// //// f `${ } ${/*1*/ fa/*2*/lse /*3*/} -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts index 8000f15d3c6..6b9daa60dcc 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// +//// //// f `${ undefined } ${ undefined } ${/*1*/ 10/*2*/./*3*/01 /*4*/} ` -test.markers().forEach(m => { - goTo.position(m.position); - +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(4); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts index aee06c1df53..cbcc55a2f22 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts @@ -4,12 +4,10 @@ //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } -//// -//// f `${/*1*/ /*2*/ /*3*/} ${ - -test.markers().forEach(m => { - goTo.position(m.position); +//// +//// f `${/*1*/ /*2*/ /*3*/} ${ +goTo.eachMarker(() => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); diff --git a/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts b/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts index 3e60456f389..92d288dcb2a 100644 --- a/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts +++ b/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts @@ -17,9 +17,8 @@ //// } ////} - test.markers().forEach((marker) => { - goTo.position(marker.position, marker.fileName); - verify.memberListContains("T"); - verify.memberListContains("U"); - verify.memberListContains("M"); +goTo.eachMarker(() => { + verify.memberListContains("T"); + verify.memberListContains("U"); + verify.memberListContains("M"); }); From a6c5306479d1ca150657967f77fa2a195db4b793 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 19 Jan 2017 13:58:09 -0800 Subject: [PATCH 136/175] Allow object intersection types as class/interface base types --- src/compiler/checker.ts | 53 ++++++++++++++++++++++++++-------------- src/compiler/types.ts | 7 ++++-- src/services/services.ts | 2 +- src/services/types.ts | 2 +- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 756a2b2d3b1..9cc5fb111cd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3732,11 +3732,16 @@ namespace ts { return getObjectFlags(type) & ObjectFlags.Reference ? (type).target : type; } - function hasBaseType(type: InterfaceType, checkBase: InterfaceType) { + function hasBaseType(type: BaseType, checkBase: BaseType) { return check(type); - function check(type: InterfaceType): boolean { - const target = getTargetType(type); - return target === checkBase || forEach(getBaseTypes(target), check); + function check(type: BaseType): boolean { + if (getObjectFlags(type) & (ObjectFlags.ClassOrInterface | ObjectFlags.Reference)) { + const target = getTargetType(type); + return target === checkBase || forEach(getBaseTypes(target), check); + } + else if (type.flags & TypeFlags.Intersection) { + return forEach((type).types, check); + } } } @@ -3862,7 +3867,7 @@ namespace ts { return type.resolvedBaseConstructorType; } - function getBaseTypes(type: InterfaceType): ObjectType[] { + function getBaseTypes(type: InterfaceType): BaseType[] { if (!type.resolvedBaseTypes) { if (type.objectFlags & ObjectFlags.Tuple) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; @@ -3922,11 +3927,11 @@ namespace ts { if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & ObjectFlags.ClassOrInterface)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } - if (type === baseType || hasBaseType(baseType, type)) { + if (type === baseType || hasBaseType(baseType, type)) { error(valueDecl, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); return; @@ -3951,6 +3956,13 @@ namespace ts { return true; } + // A valid base type is any non-generic object type or intersection of non-generic + // object types. + function isValidBaseType(type: Type): boolean { + return type.flags & TypeFlags.Object && !isGenericMappedType(type) || + type.flags & TypeFlags.Intersection && !forEach((type).types, t => !isValidBaseType(t)); + } + function resolveBaseTypesOfInterface(type: InterfaceType): void { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (const declaration of type.symbol.declarations) { @@ -3958,8 +3970,8 @@ namespace ts { for (const node of getInterfaceBaseTypeNodes(declaration)) { const baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getObjectFlags(getTargetType(baseType)) & ObjectFlags.ClassOrInterface) { - if (type !== baseType && !hasBaseType(baseType, type)) { + if (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; } @@ -4317,6 +4329,9 @@ namespace ts { return createTypeReference((type).target, concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); } + if (type.flags & TypeFlags.Intersection) { + return getIntersectionType(map((type).types, t => getTypeWithThisArgument(t, thisArgument))); + } return type; } @@ -4350,8 +4365,8 @@ namespace ts { } const thisArgument = lastOrUndefined(typeArguments); for (const baseType of baseTypes) { - const instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + const instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Call)); constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Construct)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, IndexKind.String); @@ -18216,16 +18231,18 @@ namespace ts { return; } + const propDeclaration = prop.valueDeclaration; + // index is numeric and property name is not valid numeric literal - if (indexKind === IndexKind.Number && !isNumericName(prop.valueDeclaration.name)) { + if (indexKind === IndexKind.Number && propDeclaration && !isNumericName(propDeclaration.name)) { return; } // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class let errorNode: Node; - if (prop.valueDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -18364,7 +18381,7 @@ namespace ts { checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol.valueDeclaration && + if (baseType.symbol && baseType.symbol.valueDeclaration && !isInAmbientContext(baseType.symbol.valueDeclaration) && baseType.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) { if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) { @@ -18437,7 +18454,7 @@ namespace ts { return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined); } - function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: ObjectType): void { + function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: BaseType): void { // TypeScript 1.0 spec (April 2014): 8.2.3 // A derived class inherits all members from its base class it doesn't override. @@ -18454,7 +18471,7 @@ namespace ts { // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration - const baseProperties = getPropertiesOfObjectType(baseType); + const baseProperties = getPropertiesOfType(baseType); for (const baseProperty of baseProperties) { const base = getTargetSymbol(baseProperty); @@ -18578,7 +18595,7 @@ namespace ts { let ok = true; for (const base of baseTypes) { - const properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (const prop of properties) { const existing = seen.get(prop.name); if (!existing) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 51347c8d3df..b834d73300a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2358,7 +2358,7 @@ getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; + getBaseTypes(type: InterfaceType): BaseType[]; getReturnTypeOfSignature(signature: Signature): Type; /** * Gets the type of a parameter at a given position in a signature. @@ -2910,9 +2910,12 @@ /* @internal */ resolvedBaseConstructorType?: Type; // Resolved base constructor type of class /* @internal */ - resolvedBaseTypes: ObjectType[]; // Resolved base types + resolvedBaseTypes: BaseType[]; // Resolved base types } + // Object type or intersection of object types + export type BaseType = ObjectType | IntersectionType; + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; // Declared members declaredCallSignatures: Signature[]; // Declared call signatures diff --git a/src/services/services.ts b/src/services/services.ts index 26374eccbfd..04cb233557f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -379,7 +379,7 @@ namespace ts { getNumberIndexType(): Type { return this.checker.getIndexTypeOfType(this, IndexKind.Number); } - getBaseTypes(): ObjectType[] { + getBaseTypes(): BaseType[] { return this.flags & TypeFlags.Object && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface) ? this.checker.getBaseTypes(this) : undefined; diff --git a/src/services/types.ts b/src/services/types.ts index 88ffe2950ce..f410eb5b401 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -33,7 +33,7 @@ namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; + getBaseTypes(): BaseType[]; getNonNullableType(): Type; } From d22b963b0bd4984597e003ca4267e1dca6f44183 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 19 Jan 2017 13:51:34 -0800 Subject: [PATCH 137/175] Add test for decorator referencing alias named Event --- .../reference/metadataOfEventAlias.js | 38 +++++++++++++++++++ .../reference/metadataOfEventAlias.symbols | 23 +++++++++++ .../reference/metadataOfEventAlias.types | 23 +++++++++++ tests/cases/compiler/metadataOfEventAlias.ts | 14 +++++++ 4 files changed, 98 insertions(+) create mode 100644 tests/baselines/reference/metadataOfEventAlias.js create mode 100644 tests/baselines/reference/metadataOfEventAlias.symbols create mode 100644 tests/baselines/reference/metadataOfEventAlias.types create mode 100644 tests/cases/compiler/metadataOfEventAlias.ts diff --git a/tests/baselines/reference/metadataOfEventAlias.js b/tests/baselines/reference/metadataOfEventAlias.js new file mode 100644 index 00000000000..a79a2daa5d9 --- /dev/null +++ b/tests/baselines/reference/metadataOfEventAlias.js @@ -0,0 +1,38 @@ +//// [tests/cases/compiler/metadataOfEventAlias.ts] //// + +//// [event.ts] + +export interface Event { title: string }; + +//// [test.ts] +import { Event } from './event'; +function Input(target: any, key: string): void { } +export class SomeClass { + @Input event: Event; +} + +//// [event.js] +"use strict"; +; +//// [test.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +function Input(target, key) { } +var SomeClass = (function () { + function SomeClass() { + } + return SomeClass; +}()); +__decorate([ + Input, + __metadata("design:type", event_1.Event) +], SomeClass.prototype, "event", void 0); +exports.SomeClass = SomeClass; diff --git a/tests/baselines/reference/metadataOfEventAlias.symbols b/tests/baselines/reference/metadataOfEventAlias.symbols new file mode 100644 index 00000000000..441714e63e6 --- /dev/null +++ b/tests/baselines/reference/metadataOfEventAlias.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/event.ts === + +export interface Event { title: string }; +>Event : Symbol(Event, Decl(event.ts, 0, 0)) +>title : Symbol(Event.title, Decl(event.ts, 1, 24)) + +=== tests/cases/compiler/test.ts === +import { Event } from './event'; +>Event : Symbol(Event, Decl(test.ts, 0, 8)) + +function Input(target: any, key: string): void { } +>Input : Symbol(Input, Decl(test.ts, 0, 32)) +>target : Symbol(target, Decl(test.ts, 1, 15)) +>key : Symbol(key, Decl(test.ts, 1, 27)) + +export class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(test.ts, 1, 50)) + + @Input event: Event; +>Input : Symbol(Input, Decl(test.ts, 0, 32)) +>event : Symbol(SomeClass.event, Decl(test.ts, 2, 24)) +>Event : Symbol(Event, Decl(test.ts, 0, 8)) +} diff --git a/tests/baselines/reference/metadataOfEventAlias.types b/tests/baselines/reference/metadataOfEventAlias.types new file mode 100644 index 00000000000..b644552f9c2 --- /dev/null +++ b/tests/baselines/reference/metadataOfEventAlias.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/event.ts === + +export interface Event { title: string }; +>Event : Event +>title : string + +=== tests/cases/compiler/test.ts === +import { Event } from './event'; +>Event : any + +function Input(target: any, key: string): void { } +>Input : (target: any, key: string) => void +>target : any +>key : string + +export class SomeClass { +>SomeClass : SomeClass + + @Input event: Event; +>Input : (target: any, key: string) => void +>event : Event +>Event : Event +} diff --git a/tests/cases/compiler/metadataOfEventAlias.ts b/tests/cases/compiler/metadataOfEventAlias.ts new file mode 100644 index 00000000000..c62e1480c89 --- /dev/null +++ b/tests/cases/compiler/metadataOfEventAlias.ts @@ -0,0 +1,14 @@ +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @target: es5 +// @includeBuiltFile: lib.d.ts + +// @filename: event.ts +export interface Event { title: string }; + +// @filename: test.ts +import { Event } from './event'; +function Input(target: any, key: string): void { } +export class SomeClass { + @Input event: Event; +} \ No newline at end of file From 679a7ec04f544d05104cc11ba3e6f99da6ac98b2 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 19 Jan 2017 14:27:53 -0800 Subject: [PATCH 138/175] Use the value symbol for decorator purpose only if it is same as typesymbol Fixes #13155 --- src/compiler/checker.ts | 21 +++++++++++-------- .../reference/metadataOfEventAlias.js | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 756a2b2d3b1..ad0a8dbaebb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20518,18 +20518,21 @@ namespace ts { function getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); - const globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return TypeReferenceSerializationKind.Promise; - } - - const constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + const globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return TypeReferenceSerializationKind.Promise; + } + + const constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { return TypeReferenceSerializationKind.ObjectType; diff --git a/tests/baselines/reference/metadataOfEventAlias.js b/tests/baselines/reference/metadataOfEventAlias.js index a79a2daa5d9..8a22a90bc2e 100644 --- a/tests/baselines/reference/metadataOfEventAlias.js +++ b/tests/baselines/reference/metadataOfEventAlias.js @@ -33,6 +33,6 @@ var SomeClass = (function () { }()); __decorate([ Input, - __metadata("design:type", event_1.Event) + __metadata("design:type", Object) ], SomeClass.prototype, "event", void 0); exports.SomeClass = SomeClass; From 1c2f7f866bd19d8ebbf3a4fe35b096bf512efba2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 19 Jan 2017 14:30:53 -0800 Subject: [PATCH 139/175] Improve efficiency of union/intersection resolved property caching --- src/compiler/checker.ts | 40 +++++++++++++++++++--------------------- src/compiler/types.ts | 4 +++- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9cc5fb111cd..1ca1cd9cf74 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4754,28 +4754,26 @@ namespace ts { } function getPropertiesOfUnionOrIntersectionType(type: UnionOrIntersectionType): Symbol[] { - for (const current of type.types) { - for (const prop of getPropertiesOfType(current)) { - getUnionOrIntersectionProperty(type, prop.name); - } - // The properties of a union type are those that are present in all constituent types, so - // we only need to check the properties of the first type - if (type.flags & TypeFlags.Union) { - break; - } - } - const props = type.resolvedProperties; - if (props) { - const result: Symbol[] = []; - props.forEach(prop => { - // We need to filter out partial properties in union types - if (!(prop.flags & SymbolFlags.SyntheticProperty && (prop).isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + const members = createMap(); + for (const current of type.types) { + for (const prop of getPropertiesOfType(current)) { + if (!members.has(prop.name)) { + const combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } } - }); - return result; + // The properties of a union type are those that are present in all constituent types, so + // we only need to check the properties of the first type + if (type.flags & TypeFlags.Union) { + break; + } + } + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type: Type): Symbol[] { @@ -4943,7 +4941,7 @@ namespace ts { // these partial properties when identifying discriminant properties, but otherwise they are filtered out // and do not appear to be present in the union type. function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: string): Symbol { - const properties = type.resolvedProperties || (type.resolvedProperties = createMap()); + const properties = type.propertyCache || (type.propertyCache = createMap()); let property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b834d73300a..65cd4031613 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2948,7 +2948,9 @@ export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types /* @internal */ - resolvedProperties: SymbolTable; // Cache of resolved properties + propertyCache: SymbolTable; // Cache of resolved properties + /* @internal */ + resolvedProperties: Symbol[]; /* @internal */ resolvedIndexType: IndexType; /* @internal */ From c51e2867f50de63db151310da03b829d667becc9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 19 Jan 2017 14:47:26 -0800 Subject: [PATCH 140/175] Allow object intersection types in class implements clauses --- src/compiler/checker.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1ca1cd9cf74..450fcfe1da4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18411,8 +18411,7 @@ namespace ts { if (produceDiagnostics) { const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - const declaredType = getObjectFlags(t) & ObjectFlags.Reference ? (t).target : t; - if (getObjectFlags(declaredType) & ObjectFlags.ClassOrInterface) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } else { From f9a65e436c67b1da2e0a80274e1fba5a9afc6d61 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 19 Jan 2017 14:47:38 -0800 Subject: [PATCH 141/175] Accept new baselines --- .../reference/typeAliasesForObjectTypes.errors.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/baselines/reference/typeAliasesForObjectTypes.errors.txt b/tests/baselines/reference/typeAliasesForObjectTypes.errors.txt index d5bc01f93ba..b4ae5978049 100644 --- a/tests/baselines/reference/typeAliasesForObjectTypes.errors.txt +++ b/tests/baselines/reference/typeAliasesForObjectTypes.errors.txt @@ -1,19 +1,13 @@ -tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(4,22): error TS2312: An interface may only extend a class or another interface. -tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(5,21): error TS2422: A class may only implement another class or interface. tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(10,6): error TS2300: Duplicate identifier 'T2'. tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(11,6): error TS2300: Duplicate identifier 'T2'. -==== tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts (4 errors) ==== +==== tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts (2 errors) ==== type T1 = { x: string } // An interface can be named in an extends or implements clause, but a type alias for an object type literal cannot. interface I1 extends T1 { y: string } - ~~ -!!! error TS2312: An interface may only extend a class or another interface. class C1 implements T1 { - ~~ -!!! error TS2422: A class may only implement another class or interface. x: string; } From d11d03a06c189ffc744914e9c961c4875afea6bd Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 19 Jan 2017 17:36:16 -0800 Subject: [PATCH 142/175] Fix https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14036: Remove assert. --- src/compiler/checker.ts | 1 - .../reference/mergedDeclarations7.errors.txt | 32 +++++++++++++++++++ .../reference/mergedDeclarations7.js | 28 ++++++++++++++++ tests/cases/compiler/mergedDeclarations7.ts | 21 ++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/mergedDeclarations7.errors.txt create mode 100644 tests/baselines/reference/mergedDeclarations7.js create mode 100644 tests/cases/compiler/mergedDeclarations7.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 756a2b2d3b1..a376e091ca3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4172,7 +4172,6 @@ namespace ts { } function getDeclaredTypeOfSymbol(symbol: Symbol): Type { - Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0); if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { return getDeclaredTypeOfClassOrInterface(symbol); } diff --git a/tests/baselines/reference/mergedDeclarations7.errors.txt b/tests/baselines/reference/mergedDeclarations7.errors.txt new file mode 100644 index 00000000000..cd9b3a5e939 --- /dev/null +++ b/tests/baselines/reference/mergedDeclarations7.errors.txt @@ -0,0 +1,32 @@ +tests/cases/compiler/test.ts(4,5): error TS2322: Type 'PassportStatic' is not assignable to type 'Passport'. + Types of property 'use' are incompatible. + Type '() => PassportStatic' is not assignable to type '() => this'. + Type 'PassportStatic' is not assignable to type 'this'. + + +==== tests/cases/compiler/passport.d.ts (0 errors) ==== + declare module 'passport' { + namespace passport { + interface Passport { + use(): this; + } + + interface PassportStatic extends Passport { + Passport: {new(): Passport}; + } + } + + const passport: passport.PassportStatic; + export = passport; + } + +==== tests/cases/compiler/test.ts (1 errors) ==== + import * as passport from "passport"; + import { Passport } from "passport"; + + let p: Passport = passport.use(); + ~ +!!! error TS2322: Type 'PassportStatic' is not assignable to type 'Passport'. +!!! error TS2322: Types of property 'use' are incompatible. +!!! error TS2322: Type '() => PassportStatic' is not assignable to type '() => this'. +!!! error TS2322: Type 'PassportStatic' is not assignable to type 'this'. \ No newline at end of file diff --git a/tests/baselines/reference/mergedDeclarations7.js b/tests/baselines/reference/mergedDeclarations7.js new file mode 100644 index 00000000000..e3d1ddc6e0e --- /dev/null +++ b/tests/baselines/reference/mergedDeclarations7.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/mergedDeclarations7.ts] //// + +//// [passport.d.ts] +declare module 'passport' { + namespace passport { + interface Passport { + use(): this; + } + + interface PassportStatic extends Passport { + Passport: {new(): Passport}; + } + } + + const passport: passport.PassportStatic; + export = passport; +} + +//// [test.ts] +import * as passport from "passport"; +import { Passport } from "passport"; + +let p: Passport = passport.use(); + +//// [test.js] +"use strict"; +var passport = require("passport"); +var p = passport.use(); diff --git a/tests/cases/compiler/mergedDeclarations7.ts b/tests/cases/compiler/mergedDeclarations7.ts new file mode 100644 index 00000000000..fc0945f4419 --- /dev/null +++ b/tests/cases/compiler/mergedDeclarations7.ts @@ -0,0 +1,21 @@ +// @filename: passport.d.ts +declare module 'passport' { + namespace passport { + interface Passport { + use(): this; + } + + interface PassportStatic extends Passport { + Passport: {new(): Passport}; + } + } + + const passport: passport.PassportStatic; + export = passport; +} + +//@filename: test.ts +import * as passport from "passport"; +import { Passport } from "passport"; + +let p: Passport = passport.use(); \ No newline at end of file From 21c2c0e78607cab6fac463b8b227d63189f1306f Mon Sep 17 00:00:00 2001 From: falsandtru Date: Fri, 20 Jan 2017 23:05:45 +0900 Subject: [PATCH 143/175] Fix regressions --- src/lib/es2015.collection.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index 6a2c43cd050..75a11b5eb17 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -4,7 +4,7 @@ interface Map { forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; readonly size: number; } @@ -26,7 +26,7 @@ interface WeakMap { delete(key: K): boolean; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; } interface WeakMapConstructor { From a9af10b030d2167ad7612a98df28f4084e95a005 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 20 Jan 2017 06:16:08 -0800 Subject: [PATCH 144/175] Intersections as their own 'this' type --- src/compiler/checker.ts | 16 ++++++++++++---- src/compiler/core.ts | 4 ++++ src/compiler/types.ts | 5 ++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 450fcfe1da4..6de1b5aa624 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4326,10 +4326,13 @@ namespace ts { function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { if (getObjectFlags(type) & ObjectFlags.Reference) { - return createTypeReference((type).target, - concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); + const target = (type).target; + const typeArguments = (type).typeArguments; + if (length(target.typeParameters) === length(typeArguments)) { + return createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType])); + } } - if (type.flags & TypeFlags.Intersection) { + else if (type.flags & TypeFlags.Intersection) { return getIntersectionType(map((type).types, t => getTypeWithThisArgument(t, thisArgument))); } return type; @@ -4858,6 +4861,10 @@ namespace ts { } } + function getApparentTypeOfIntersectionType(type: IntersectionType) { + return type.resolvedIndexType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + /** * For a type parameter, return the base constraint of the type parameter. For the string, number, * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the @@ -4865,7 +4872,8 @@ namespace ts { */ function getApparentType(type: Type): Type { const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfType(type) || emptyObjectType : type; - return t.flags & TypeFlags.StringLike ? globalStringType : + return t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(type) : + t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType() : diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 654b1bc2912..47a6e2e70a8 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -202,6 +202,10 @@ namespace ts { GreaterThan = 1 } + export function length(array: any[]) { + return array ? array.length : 0; + } + /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 65cd4031613..6b5c670a9fa 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2961,7 +2961,10 @@ export interface UnionType extends UnionOrIntersectionType { } - export interface IntersectionType extends UnionOrIntersectionType { } + export interface IntersectionType extends UnionOrIntersectionType { + /* @internal */ + resolvedApparentType: Type; + } export type StructuredType = ObjectType | UnionType | IntersectionType; From 1267fd3030a588eb29dcf7ad0e4bb3c8887a59fb Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 20 Jan 2017 06:41:57 -0800 Subject: [PATCH 145/175] Don't use nameTable for type keywords, and don't handle keyof. --- src/services/findAllReferences.ts | 4 +--- src/services/services.ts | 17 ++++------------- src/services/utilities.ts | 3 +-- tests/cases/fourslash/findAllRefsPrimitive.ts | 2 -- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 68eb684fe25..82a5da453b7 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -353,9 +353,7 @@ namespace ts.FindAllReferences { const references: ReferenceEntry[] = []; for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - if (sourceFileHasName(sourceFile, name)) { - addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); - } + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); } return [{ definition, references }]; diff --git a/src/services/services.ts b/src/services/services.ts index 20204165328..1fe2235a4ba 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1975,20 +1975,11 @@ namespace ts { setNameTable((node).text, node); } break; - case SyntaxKind.TypeOperator: - setNameTable(tokenToString((node as ts.TypeOperatorNode).operator), node); - forEachChild(node, walk); - break; default: - if (isTypeKeyword(node.kind)) { - setNameTable(tokenToString(node.kind), node); - } - else { - forEachChild(node, walk); - if (node.jsDoc) { - for (const jsDoc of node.jsDoc) { - forEachChild(jsDoc, walk); - } + forEachChild(node, walk); + if (node.jsDoc) { + for (const jsDoc of node.jsDoc) { + forEachChild(jsDoc, walk); } } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index dd337238da3..a1680da69c3 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); @@ -1126,7 +1126,6 @@ namespace ts { case SyntaxKind.BooleanKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.NumberKeyword: - case SyntaxKind.KeyOfKeyword: case SyntaxKind.ObjectKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.SymbolKeyword: diff --git a/tests/cases/fourslash/findAllRefsPrimitive.ts b/tests/cases/fourslash/findAllRefsPrimitive.ts index 9bd3d62eabb..51c463843e1 100644 --- a/tests/cases/fourslash/findAllRefsPrimitive.ts +++ b/tests/cases/fourslash/findAllRefsPrimitive.ts @@ -21,8 +21,6 @@ ////function v(v: [|void|]): [|void|]; -////function k(x: [|keyof|] Date): [|keyof|] Date; - // @Filename: b.ts // const z: [|any|] = 0; From c16c7d56c0a4e9f7e11dd134cffcdbb1eef5916c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 20 Jan 2017 09:17:14 -0800 Subject: [PATCH 146/175] Allow base constructor types to be intersections --- src/compiler/checker.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6de1b5aa624..a5058bdf7f2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3810,7 +3810,7 @@ namespace ts { } function isConstructorType(type: Type): boolean { - return type.flags & TypeFlags.Object && getSignaturesOfType(type, SignatureKind.Construct).length > 0; + return isValidBaseType(type) && getSignaturesOfType(type, SignatureKind.Construct).length > 0; } function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments { @@ -3849,7 +3849,7 @@ namespace ts { return unknownType; } const baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & TypeFlags.Object) { + if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -3890,7 +3890,7 @@ namespace ts { function resolveBaseTypesOfClass(type: InterfaceType): void { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; const baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & TypeFlags.Object)) { + if (!(baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection))) { return; } const baseTypeNode = getBaseTypeNodeOfClass(type); @@ -4591,9 +4591,9 @@ namespace ts { constructSignatures = getDefaultConstructSignatures(classType); } const baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & TypeFlags.Object) { + if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } const numberIndexInfo = symbol.flags & SymbolFlags.Enum ? enumNumberIndexInfo : undefined; From 1183129bda17ff969334b1f1a055d463f8028535 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 20 Jan 2017 10:17:11 -0800 Subject: [PATCH 147/175] getFirstToken returns jsdoc as single comment This is a bit odd, but it's the way that 2.0 and earlier behaved. 2.1 broke it. --- src/compiler/types.ts | 2 +- src/harness/unittests/jsDocParsing.ts | 14 ++++++++++++++ src/services/services.ts | 9 ++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 51347c8d3df..f0e20ecd4bf 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -421,7 +421,7 @@ LastBinaryOperator = CaretEqualsToken, FirstNode = QualifiedName, FirstJSDocNode = JSDocTypeExpression, - LastJSDocNode = JSDocLiteralType, + LastJSDocNode = JSDocNeverKeyword, FirstJSDocTagNode = JSDocComment, LastJSDocTagNode = JSDocNeverKeyword } diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index addd01b0e0a..3cafc9d49ae 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -288,5 +288,19 @@ namespace ts { */`); }); }); + describe("getFirstToken", () => { + it("gets jsdoc", () => { + const first = ts.createSourceFile("foo.ts", "/** comment */var a = true;", ts.ScriptTarget.ES5, /*setParentNodes*/ true); + assert.isDefined(first); + assert.equal(first.kind, 263); + }); + }); + describe("getLastToken", () => { + it("gets jsdoc", () => { + const last = ts.createSourceFile("foo.ts", "var a = true;/** comment */", ts.ScriptTarget.ES5, /*setParentNodes*/ true); + assert.isDefined(last); + assert.equal(last.kind, 263); + }); + }); }); } diff --git a/src/services/services.ts b/src/services/services.ts index 26374eccbfd..cdd789166bc 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -194,8 +194,9 @@ namespace ts { } const child = children[0]; - - return child.kind < SyntaxKind.FirstNode ? child : child.getFirstToken(sourceFile); + return child.kind < SyntaxKind.FirstNode || SyntaxKind.FirstJSDocNode <= child.kind && child.kind <= SyntaxKind.LastJSDocNode ? + child : + child.getFirstToken(sourceFile); } public getLastToken(sourceFile?: SourceFile): Node { @@ -206,7 +207,9 @@ namespace ts { return undefined; } - return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile); + return child.kind < SyntaxKind.FirstNode || SyntaxKind.FirstJSDocNode <= child.kind && child.kind <= SyntaxKind.LastJSDocNode ? + child : + child.getLastToken(sourceFile); } } From 8886cefe58c4674589f8f96067effcbb3dc77aa8 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 20 Jan 2017 08:12:00 -0800 Subject: [PATCH 148/175] Clean up code for getting emitted files --- src/compiler/emitter.ts | 4 +- src/compiler/program.ts | 2 +- src/compiler/utilities.ts | 186 +++++------------- .../reference/noBundledEmitFromNodeModules.js | 20 ++ .../noBundledEmitFromNodeModules.symbols | 9 + .../noBundledEmitFromNodeModules.types | 9 + .../compiler/noBundledEmitFromNodeModules.ts | 10 + 7 files changed, 98 insertions(+), 142 deletions(-) create mode 100644 tests/baselines/reference/noBundledEmitFromNodeModules.js create mode 100644 tests/baselines/reference/noBundledEmitFromNodeModules.symbols create mode 100644 tests/baselines/reference/noBundledEmitFromNodeModules.types create mode 100644 tests/cases/compiler/noBundledEmitFromNodeModules.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2ff342138c8..1c4662fa587 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -73,7 +73,7 @@ namespace ts { // Emit each output file performance.mark("beforePrint"); - forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + forEachEmittedFile(host, transformed, emitFile, emitOnlyDtsFiles); performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree @@ -88,7 +88,7 @@ namespace ts { sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) { + function emitFile({ jsFilePath, sourceMapFilePath, declarationFilePath }: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) { // Make sure not to write js file and source map file if any of them cannot be written if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 324a21f229e..851e206d448 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -439,7 +439,7 @@ namespace ts { function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - const emittedFiles = filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + const emittedFiles = filter(files, file => sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary)); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, currentDirectory); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 932e75d0345..f59d384e490 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2568,108 +2568,25 @@ namespace ts { * @param host An EmitHost. * @param targetSourceFile An optional target source file to emit. */ - export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile) { + export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[] { const options = host.getCompilerOptions(); + const isSourceFileFromExternalLibrary = (file: SourceFile) => host.isSourceFileFromExternalLibrary(file); if (options.outFile || options.out) { const moduleKind = getEmitModuleKind(options); const moduleEmitEnabled = moduleKind === ModuleKind.AMD || moduleKind === ModuleKind.System; - const sourceFiles = getAllEmittableSourceFiles(); // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified - return filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + return filter(host.getSourceFiles(), sourceFile => + (moduleEmitEnabled || !isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary)); } else { - const sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, file => host.isSourceFileFromExternalLibrary(file)); - } - - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? filter(host.getSourceFiles(), sourceFile => !isSourceFileJavaScript(sourceFile)) : host.getSourceFiles(); + const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return filter(sourceFiles, sourceFile => sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary)); } } - /** Don't call this for `--outFile`, just for `--outDir` or plain emit. */ - export function filterSourceFilesInDirectory(sourceFiles: SourceFile[], isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): SourceFile[] { - return filter(sourceFiles, file => shouldEmitInDirectory(file, isSourceFileFromExternalLibrary)); - } - - function isNonDeclarationFile(sourceFile: SourceFile) { - return !isDeclarationFile(sourceFile); - } - - /** - * Whether a file should be emitted in a non-`--outFile` case. - * Don't emit if source file is a declaration file, or was located under node_modules - */ - function shouldEmitInDirectory(sourceFile: SourceFile, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): boolean { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - - function isBundleEmitNonExternalModule(sourceFile: SourceFile) { - return isNonDeclarationFile(sourceFile) && !isExternalModule(sourceFile); - } - - /** - * Iterates over each source file to emit. The source files are expected to have been - * transformed for use by the pretty printer. - * - * Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support - * transformations. - * - * @param host An EmitHost. - * @param sourceFiles The transformed source files to emit. - * @param action The action to execute. - */ - export function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], - action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, - emitOnlyDtsFiles?: boolean) { - const options = host.getCompilerOptions(); - // Emit on each source file - if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (const sourceFile of sourceFiles) { - // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - - function onSingleFileEmit(host: EmitHost, sourceFile: SourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - let extension = ".js"; - if (options.jsx === JsxEmit.Preserve) { - if (isSourceFileJavaScript(sourceFile)) { - if (fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === LanguageVariant.JSX) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); - } - - function onBundledEmit(sourceFiles: SourceFile[]) { - if (sourceFiles.length) { - const jsFilePath = options.outFile || options.out; - const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, /*isBundledEmit*/ true); - } - } - } - - function getSourceMapFilePath(jsFilePath: string, options: CompilerOptions) { - return options.sourceMap ? jsFilePath + ".map" : undefined; + /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ + export function sourceFileMayBeEmitted(sourceFile: SourceFile, options: CompilerOptions, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } /** @@ -2685,64 +2602,55 @@ namespace ts { action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, targetSourceFile?: SourceFile, emitOnlyDtsFiles?: boolean) { + forEachEmittedFile(host, getSourceFilesToEmit(host, targetSourceFile), action, emitOnlyDtsFiles); + } + + /** + * Iterates over each source file to emit. + */ + export function forEachEmittedFile(host: EmitHost, sourceFiles: SourceFile[], + action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, + emitOnlyDtsFiles?: boolean) { const options = host.getCompilerOptions(); - // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(host); + if (sourceFiles.length) { + const jsFilePath = options.outFile || options.out; + const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined; + action({ jsFilePath, sourceMapFilePath, declarationFilePath }, sourceFiles, /*isBundledEmit*/true, emitOnlyDtsFiles); + } } else { - const sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; for (const sourceFile of sourceFiles) { - if (shouldEmitInDirectory(sourceFile, file => host.isSourceFileFromExternalLibrary(file))) { - onSingleFileEmit(host, sourceFile); - } + const options = host.getCompilerOptions(); + const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + const declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath, sourceMapFilePath, declarationFilePath }, [sourceFile], /*isBundledEmit*/false, emitOnlyDtsFiles); } } + } - function onSingleFileEmit(host: EmitHost, sourceFile: SourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - let extension = ".js"; - if (options.jsx === JsxEmit.Preserve) { - if (isSourceFileJavaScript(sourceFile)) { - if (fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === LanguageVariant.JSX) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - const declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - const emitFileNames: EmitFileNames = { - jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath - }; - action(emitFileNames, [sourceFile], /*isBundledEmit*/false, emitOnlyDtsFiles); - } + function getSourceMapFilePath(jsFilePath: string, options: CompilerOptions) { + return options.sourceMap ? jsFilePath + ".map" : undefined; + } - function onBundledEmit(host: EmitHost) { - // Can emit only sources that are not declaration file and are either non module code or module with - // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - const bundledSources = filter(getSourceFilesToEmit(host), - sourceFile => !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!isExternalModule(sourceFile) || - !!getEmitModuleKind(options))); - if (bundledSources.length) { - const jsFilePath = options.outFile || options.out; - const emitFileNames: EmitFileNames = { - jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, /*isBundledEmit*/true, emitOnlyDtsFiles); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + function getOutputExtension(sourceFile: SourceFile, options: CompilerOptions): string { + if (options.jsx === JsxEmit.Preserve) { + if (isSourceFileJavaScript(sourceFile)) { + if (fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; + } + } + else if (sourceFile.languageVariant === LanguageVariant.JSX) { + // TypeScript source file preserving JSX syntax + return ".jsx"; } } + return ".js"; } export function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) { diff --git a/tests/baselines/reference/noBundledEmitFromNodeModules.js b/tests/baselines/reference/noBundledEmitFromNodeModules.js new file mode 100644 index 00000000000..67216a408af --- /dev/null +++ b/tests/baselines/reference/noBundledEmitFromNodeModules.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/noBundledEmitFromNodeModules.ts] //// + +//// [index.ts] + +export class C {} + +//// [a.ts] +import { C } from "projB"; + + +//// [out.js] +System.register("a", [], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + } + }; +}); diff --git a/tests/baselines/reference/noBundledEmitFromNodeModules.symbols b/tests/baselines/reference/noBundledEmitFromNodeModules.symbols new file mode 100644 index 00000000000..a1f6c67e4b4 --- /dev/null +++ b/tests/baselines/reference/noBundledEmitFromNodeModules.symbols @@ -0,0 +1,9 @@ +=== /a.ts === +import { C } from "projB"; +>C : Symbol(C, Decl(a.ts, 0, 8)) + +=== /node_modules/projB/index.ts === + +export class C {} +>C : Symbol(C, Decl(index.ts, 0, 0)) + diff --git a/tests/baselines/reference/noBundledEmitFromNodeModules.types b/tests/baselines/reference/noBundledEmitFromNodeModules.types new file mode 100644 index 00000000000..a11bad24aaf --- /dev/null +++ b/tests/baselines/reference/noBundledEmitFromNodeModules.types @@ -0,0 +1,9 @@ +=== /a.ts === +import { C } from "projB"; +>C : typeof C + +=== /node_modules/projB/index.ts === + +export class C {} +>C : C + diff --git a/tests/cases/compiler/noBundledEmitFromNodeModules.ts b/tests/cases/compiler/noBundledEmitFromNodeModules.ts new file mode 100644 index 00000000000..66c71a58489 --- /dev/null +++ b/tests/cases/compiler/noBundledEmitFromNodeModules.ts @@ -0,0 +1,10 @@ +// @outFile: out.js +// @module: system +// @moduleResolution: node +// @noImplicitReferences: true + +// @fileName: /node_modules/projB/index.ts +export class C {} + +// @fileName: /a.ts +import { C } from "projB"; From 108d8cf584406824a569cc4b18428d5dc26cbdd1 Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sat, 21 Jan 2017 11:36:18 +1100 Subject: [PATCH 149/175] export the type `Log` that is used by exported functions closes https://github.com/Microsoft/TypeScript/issues/13559 --- src/services/completions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index d6d3a9ce060..5a08dbcb9c8 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.Completions { - type Log = (message: string) => void; + 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)) { From 4ee8213dde3a08b29d3add176cae92bdb20c5415 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 20 Jan 2017 19:59:26 -0800 Subject: [PATCH 150/175] do not capture 'arguments' when property name 'arguments' is met (#13600) do not capture 'arguments' when property name 'arguments' is met --- src/compiler/checker.ts | 3 +- src/compiler/transformers/es2015.ts | 2 +- .../reference/argumentsAsPropertyName.js | 29 ++++++++++ .../reference/argumentsAsPropertyName.symbols | 43 ++++++++++++++ .../reference/argumentsAsPropertyName.types | 57 +++++++++++++++++++ .../cases/compiler/argumentsAsPropertyName.ts | 15 +++++ 6 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/argumentsAsPropertyName.js create mode 100644 tests/baselines/reference/argumentsAsPropertyName.symbols create mode 100644 tests/baselines/reference/argumentsAsPropertyName.types create mode 100644 tests/cases/compiler/argumentsAsPropertyName.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a1ad9f0344d..5f80444c73e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20222,7 +20222,8 @@ namespace ts { if (!isGeneratedIdentifier(node)) { node = getParseTreeNode(node, isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + const isPropertyName = node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node; + return !isPropertyName && getReferencedValueSymbol(node) === argumentsSymbol; } } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index d0b9ef7455f..d1dab8eeb7a 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -585,7 +585,7 @@ namespace ts { if (isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments")); diff --git a/tests/baselines/reference/argumentsAsPropertyName.js b/tests/baselines/reference/argumentsAsPropertyName.js new file mode 100644 index 00000000000..a4197c0a1d2 --- /dev/null +++ b/tests/baselines/reference/argumentsAsPropertyName.js @@ -0,0 +1,29 @@ +//// [argumentsAsPropertyName.ts] +// target: es5 +type MyType = { + arguments: Array +} + +declare function use(s: any); + +function myFunction(myType: MyType) { + for (let i = 0; i < 10; i++) { + use(myType.arguments[i]); + // create closure so that tsc will turn loop body into function + const x = 5; + [1, 2, 3].forEach(function(j) { use(x); }) + } +} + +//// [argumentsAsPropertyName.js] +function myFunction(myType) { + var _loop_1 = function (i) { + use(myType.arguments[i]); + // create closure so that tsc will turn loop body into function + var x = 5; + [1, 2, 3].forEach(function (j) { use(x); }); + }; + for (var i = 0; i < 10; i++) { + _loop_1(i); + } +} diff --git a/tests/baselines/reference/argumentsAsPropertyName.symbols b/tests/baselines/reference/argumentsAsPropertyName.symbols new file mode 100644 index 00000000000..1e3e41abb6e --- /dev/null +++ b/tests/baselines/reference/argumentsAsPropertyName.symbols @@ -0,0 +1,43 @@ +=== tests/cases/compiler/argumentsAsPropertyName.ts === +// target: es5 +type MyType = { +>MyType : Symbol(MyType, Decl(argumentsAsPropertyName.ts, 0, 0)) + + arguments: Array +>arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +declare function use(s: any); +>use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) +>s : Symbol(s, Decl(argumentsAsPropertyName.ts, 5, 21)) + +function myFunction(myType: MyType) { +>myFunction : Symbol(myFunction, Decl(argumentsAsPropertyName.ts, 5, 29)) +>myType : Symbol(myType, Decl(argumentsAsPropertyName.ts, 7, 20)) +>MyType : Symbol(MyType, Decl(argumentsAsPropertyName.ts, 0, 0)) + + for (let i = 0; i < 10; i++) { +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) + + use(myType.arguments[i]); +>use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) +>myType.arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) +>myType : Symbol(myType, Decl(argumentsAsPropertyName.ts, 7, 20)) +>arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) + + // create closure so that tsc will turn loop body into function + const x = 5; +>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, --, --)) +>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 new file mode 100644 index 00000000000..d0aaaa1cc72 --- /dev/null +++ b/tests/baselines/reference/argumentsAsPropertyName.types @@ -0,0 +1,57 @@ +=== tests/cases/compiler/argumentsAsPropertyName.ts === +// target: es5 +type MyType = { +>MyType : MyType + + arguments: Array +>arguments : string[] +>Array : T[] +} + +declare function use(s: any); +>use : (s: any) => any +>s : any + +function myFunction(myType: MyType) { +>myFunction : (myType: MyType) => void +>myType : MyType +>MyType : MyType + + for (let i = 0; i < 10; i++) { +>i : number +>0 : 0 +>i < 10 : boolean +>i : number +>10 : 10 +>i++ : number +>i : number + + use(myType.arguments[i]); +>use(myType.arguments[i]) : any +>use : (s: any) => any +>myType.arguments[i] : string +>myType.arguments : string[] +>myType : MyType +>arguments : string[] +>i : number + + // create closure so that tsc will turn loop body into function + const x = 5; +>x : 5 +>5 : 5 + + [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] : 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 +>j : number +>use(x) : any +>use : (s: any) => any +>x : 5 + } +} diff --git a/tests/cases/compiler/argumentsAsPropertyName.ts b/tests/cases/compiler/argumentsAsPropertyName.ts new file mode 100644 index 00000000000..ffecdaa1301 --- /dev/null +++ b/tests/cases/compiler/argumentsAsPropertyName.ts @@ -0,0 +1,15 @@ +// target: es5 +type MyType = { + arguments: Array +} + +declare function use(s: any); + +function myFunction(myType: MyType) { + for (let i = 0; i < 10; i++) { + use(myType.arguments[i]); + // create closure so that tsc will turn loop body into function + const x = 5; + [1, 2, 3].forEach(function(j) { use(x); }) + } +} \ No newline at end of file From 7d773f18e09de59fc49090307b5980529fe97d0d Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sat, 21 Jan 2017 17:07:37 +0100 Subject: [PATCH 151/175] Adds non-ambient context check --- src/compiler/checker.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5f80444c73e..2cac77bf576 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -18337,7 +18337,11 @@ namespace ts { const staticType = getTypeOfSymbol(symbol); checkTypeParameterListsIdentical(node, symbol); checkClassForDuplicateDeclarations(node); + + // Only check for reserved static identifiers on non-ambient context. + if (!isInAmbientContext(node)) { checkClassForStaticPropertyNameConflicts(node); + } const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { From 02af00fae7ce4ad63ffa9a566e6f46d48e7ca333 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sat, 21 Jan 2017 17:08:48 +0100 Subject: [PATCH 152/175] Fixes formatting --- src/compiler/checker.ts | 12 +- ...pertyNameConflictsInAmbientContext.symbols | 107 ++++++++++++++++++ 2 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.symbols diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2cac77bf576..383b92b7074 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -15722,12 +15722,12 @@ namespace ts { } } - /** + /** * Static members being set on a constructor function may conflict with built-in properties - * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable - * built-in properties. This check issues a transpile error when a class has a static + * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable + * built-in properties. This check issues a transpile error when a class has a static * member with the same name as a non-writable built-in property. - * + * * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 * @see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor @@ -18340,7 +18340,7 @@ namespace ts { // Only check for reserved static identifiers on non-ambient context. if (!isInAmbientContext(node)) { - checkClassForStaticPropertyNameConflicts(node); + checkClassForStaticPropertyNameConflicts(node); } const baseTypeNode = getClassExtendsHeritageClauseElement(node); diff --git a/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.symbols b/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.symbols new file mode 100644 index 00000000000..46297eab86a --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.symbols @@ -0,0 +1,107 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/decl.d.ts === + +// name +declare class StaticName { +>StaticName : Symbol(StaticName, Decl(decl.d.ts, 0, 0)) + + static name: number; // ok +>name : Symbol(StaticName.name, Decl(decl.d.ts, 2, 26)) + + name: string; // ok +>name : Symbol(StaticName.name, Decl(decl.d.ts, 3, 24)) +} + +declare class StaticNameFn { +>StaticNameFn : Symbol(StaticNameFn, Decl(decl.d.ts, 5, 1)) + + static name(): string; // ok +>name : Symbol(StaticNameFn.name, Decl(decl.d.ts, 7, 28)) + + name(): string; // ok +>name : Symbol(StaticNameFn.name, Decl(decl.d.ts, 8, 26)) +} + +// length +declare class StaticLength { +>StaticLength : Symbol(StaticLength, Decl(decl.d.ts, 10, 1)) + + static length: number; // ok +>length : Symbol(StaticLength.length, Decl(decl.d.ts, 13, 28)) + + length: string; // ok +>length : Symbol(StaticLength.length, Decl(decl.d.ts, 14, 26)) +} + +declare class StaticLengthFn { +>StaticLengthFn : Symbol(StaticLengthFn, Decl(decl.d.ts, 16, 1)) + + static length(): number; // ok +>length : Symbol(StaticLengthFn.length, Decl(decl.d.ts, 18, 30)) + + length(): number; // ok +>length : Symbol(StaticLengthFn.length, Decl(decl.d.ts, 19, 28)) +} + +// prototype +declare class StaticPrototype { +>StaticPrototype : Symbol(StaticPrototype, Decl(decl.d.ts, 21, 1)) + + static prototype: number; // ok +>prototype : Symbol(StaticPrototype.prototype, Decl(decl.d.ts, 24, 31)) + + prototype: string; // ok +>prototype : Symbol(StaticPrototype.prototype, Decl(decl.d.ts, 25, 29)) +} + +declare class StaticPrototypeFn { +>StaticPrototypeFn : Symbol(StaticPrototypeFn, Decl(decl.d.ts, 27, 1)) + + static prototype: any; // ok +>prototype : Symbol(StaticPrototypeFn.prototype, Decl(decl.d.ts, 29, 33)) + + prototype(): any; // ok +>prototype : Symbol(StaticPrototypeFn.prototype, Decl(decl.d.ts, 30, 26)) +} + +// caller +declare class StaticCaller { +>StaticCaller : Symbol(StaticCaller, Decl(decl.d.ts, 32, 1)) + + static caller: number; // ok +>caller : Symbol(StaticCaller.caller, Decl(decl.d.ts, 35, 28)) + + caller: string; // ok +>caller : Symbol(StaticCaller.caller, Decl(decl.d.ts, 36, 26)) +} + +declare class StaticCallerFn { +>StaticCallerFn : Symbol(StaticCallerFn, Decl(decl.d.ts, 38, 1)) + + static caller(): any; // ok +>caller : Symbol(StaticCallerFn.caller, Decl(decl.d.ts, 40, 30)) + + caller(): any; // ok +>caller : Symbol(StaticCallerFn.caller, Decl(decl.d.ts, 41, 25)) +} + +// arguments +declare class StaticArguments { +>StaticArguments : Symbol(StaticArguments, Decl(decl.d.ts, 43, 1)) + + static arguments: number; // ok +>arguments : Symbol(StaticArguments.arguments, Decl(decl.d.ts, 46, 31)) + + arguments: string; // ok +>arguments : Symbol(StaticArguments.arguments, Decl(decl.d.ts, 47, 29)) +} + +declare class StaticArgumentsFn { +>StaticArgumentsFn : Symbol(StaticArgumentsFn, Decl(decl.d.ts, 49, 1)) + + static arguments(): any; // ok +>arguments : Symbol(StaticArgumentsFn.arguments, Decl(decl.d.ts, 51, 33)) + + arguments(): any; // ok +>arguments : Symbol(StaticArgumentsFn.arguments, Decl(decl.d.ts, 52, 28)) +} + From 1e5b7c5564eeae81b4ee750703cb9cd79ae8e47f Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sat, 21 Jan 2017 17:09:09 +0100 Subject: [PATCH 153/175] Add tests --- ...icPropertyNameConflictsInAmbientContext.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsInAmbientContext.ts diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsInAmbientContext.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsInAmbientContext.ts new file mode 100644 index 00000000000..198c923b0dd --- /dev/null +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsInAmbientContext.ts @@ -0,0 +1,56 @@ + +//@Filename: decl.d.ts +// name +declare class StaticName { + static name: number; // ok + name: string; // ok +} + +declare class StaticNameFn { + static name(): string; // ok + name(): string; // ok +} + +// length +declare class StaticLength { + static length: number; // ok + length: string; // ok +} + +declare class StaticLengthFn { + static length(): number; // ok + length(): number; // ok +} + +// prototype +declare class StaticPrototype { + static prototype: number; // ok + prototype: string; // ok +} + +declare class StaticPrototypeFn { + static prototype: any; // ok + prototype(): any; // ok +} + +// caller +declare class StaticCaller { + static caller: number; // ok + caller: string; // ok +} + +declare class StaticCallerFn { + static caller(): any; // ok + caller(): any; // ok +} + +// arguments +declare class StaticArguments { + static arguments: number; // ok + arguments: string; // ok +} + +declare class StaticArgumentsFn { + static arguments(): any; // ok + arguments(): any; // ok +} From 36f6e19d9eeb1f7da92e466dede07f800d8c14a9 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sat, 21 Jan 2017 17:09:26 +0100 Subject: [PATCH 154/175] Add reference baseline --- ...ropertyNameConflictsInAmbientContext.types | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.types diff --git a/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.types b/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.types new file mode 100644 index 00000000000..233bd8a46fc --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.types @@ -0,0 +1,107 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/decl.d.ts === + +// name +declare class StaticName { +>StaticName : StaticName + + static name: number; // ok +>name : number + + name: string; // ok +>name : string +} + +declare class StaticNameFn { +>StaticNameFn : StaticNameFn + + static name(): string; // ok +>name : () => string + + name(): string; // ok +>name : () => string +} + +// length +declare class StaticLength { +>StaticLength : StaticLength + + static length: number; // ok +>length : number + + length: string; // ok +>length : string +} + +declare class StaticLengthFn { +>StaticLengthFn : StaticLengthFn + + static length(): number; // ok +>length : () => number + + length(): number; // ok +>length : () => number +} + +// prototype +declare class StaticPrototype { +>StaticPrototype : StaticPrototype + + static prototype: number; // ok +>prototype : StaticPrototype + + prototype: string; // ok +>prototype : string +} + +declare class StaticPrototypeFn { +>StaticPrototypeFn : StaticPrototypeFn + + static prototype: any; // ok +>prototype : StaticPrototypeFn + + prototype(): any; // ok +>prototype : () => any +} + +// caller +declare class StaticCaller { +>StaticCaller : StaticCaller + + static caller: number; // ok +>caller : number + + caller: string; // ok +>caller : string +} + +declare class StaticCallerFn { +>StaticCallerFn : StaticCallerFn + + static caller(): any; // ok +>caller : () => any + + caller(): any; // ok +>caller : () => any +} + +// arguments +declare class StaticArguments { +>StaticArguments : StaticArguments + + static arguments: number; // ok +>arguments : number + + arguments: string; // ok +>arguments : string +} + +declare class StaticArgumentsFn { +>StaticArgumentsFn : StaticArgumentsFn + + static arguments(): any; // ok +>arguments : () => any + + arguments(): any; // ok +>arguments : () => any +} + From ad71da0a7f36fafa8e940c388fd503c60ae6afee Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 21 Jan 2017 13:06:54 -0800 Subject: [PATCH 155/175] Fix error reporting bug --- 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 a5058bdf7f2..3242a30d381 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18240,14 +18240,14 @@ namespace ts { const propDeclaration = prop.valueDeclaration; // index is numeric and property name is not valid numeric literal - if (indexKind === IndexKind.Number && propDeclaration && !isNumericName(propDeclaration.name)) { + if (indexKind === IndexKind.Number && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class let errorNode: Node; - if (propDeclaration && propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol) { + if (propDeclaration && (propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } else if (indexDeclaration) { From 615784ad944a3e7ec392e6043c41028558aab5b4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 21 Jan 2017 13:07:06 -0800 Subject: [PATCH 156/175] Add tests --- .../interfaceExtendsObjectIntersection.ts | 55 +++++++++++++++++++ ...nterfaceExtendsObjectIntersectionErrors.ts | 49 +++++++++++++++++ .../intersection/intersectionThisTypes.ts | 40 ++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts create mode 100644 tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts create mode 100644 tests/cases/conformance/types/intersection/intersectionThisTypes.ts diff --git a/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts b/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts new file mode 100644 index 00000000000..003976a2b27 --- /dev/null +++ b/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts @@ -0,0 +1,55 @@ +// @strictNullChecks: true + +type T1 = { a: number }; +type T2 = T1 & { b: number }; +type T3 = () => void; +type T4 = new () => { a: number }; +type T5 = number[]; +type T6 = [string, number]; +type T7 = { [P in 'a' | 'b' | 'c']: string }; + +interface I1 extends T1 { x: string } +interface I2 extends T2 { x: string } +interface I3 extends T3 { x: string } +interface I4 extends T4 { x: string } +interface I5 extends T5 { x: string } +interface I6 extends T6 { x: string } +interface I7 extends T7 { x: string } + +type Constructor = new () => T; +declare function Constructor(): Constructor; + +class C1 extends Constructor() { x: string } +class C2 extends Constructor() { x: string } +class C3 extends Constructor() { x: string } +class C4 extends Constructor() { x: string } +class C5 extends Constructor() { x: string } +class C6 extends Constructor() { x: string } +class C7 extends Constructor() { x: string } + +declare function fx(x: string): string; +declare class CX { a: number } +declare enum EX { A, B, C } +declare namespace NX { export const a = 1 } + +type T10 = typeof fx; +type T11 = typeof CX; +type T12 = typeof EX; +type T13 = typeof NX; + +interface I10 extends T10 { x: string } +interface I11 extends T11 { x: string } +interface I12 extends T12 { x: string } +interface I13 extends T13 { x: string } + +type Identifiable = { _id: string } & T; + +interface I20 extends Partial { x: string } +interface I21 extends Readonly { x: string } +interface I22 extends Identifiable { x: string } +interface I23 extends Identifiable { x: string } + +class C20 extends Constructor>() { x: string } +class C21 extends Constructor>() { x: string } +class C22 extends Constructor>() { x: string } +class C23 extends Constructor>() { x: string } diff --git a/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts b/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts new file mode 100644 index 00000000000..5a2a37fc227 --- /dev/null +++ b/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts @@ -0,0 +1,49 @@ +// @strictNullChecks: true + +type T1 = { a: number }; +type T2 = T1 & { b: number }; +type T3 = number[]; +type T4 = [string, number]; +type T5 = { [P in 'a' | 'b' | 'c']: string }; + +interface I1 extends T1 { a: string } +interface I2 extends T2 { b: string } +interface I3 extends T3 { length: string } +interface I4 extends T4 { 0: number } +interface I5 extends T5 { c: number } + +type Constructor = new () => T; +declare function Constructor(): Constructor; + +class C1 extends Constructor() { a: string } +class C2 extends Constructor() { b: string } +class C3 extends Constructor() { length: string } +class C4 extends Constructor() { 0: number } +class C5 extends Constructor() { c: number } + +declare class CX { static a: string } +declare enum EX { A, B, C } +declare namespace NX { export const a = "hello" } + +type TCX = typeof CX; +type TEX = typeof EX; +type TNX = typeof NX; + +interface I10 extends TCX { a: number } +interface I11 extends TEX { C: string } +interface I12 extends TNX { a: number } +interface I14 extends TCX { [x: string]: number } +interface I15 extends TEX { [x: string]: number } +interface I16 extends TNX { [x: string]: number } + +type Identifiable = { _id: string } & T; + +interface I20 extends Partial { a: string } +interface I21 extends Readonly { a: string } +interface I22 extends Identifiable { a: string } +interface I23 extends Identifiable { a: string } + +type U = { a: number } | { b: string }; + +interface I30 extends U { x: string } +interface I31 extends T { x: string } diff --git a/tests/cases/conformance/types/intersection/intersectionThisTypes.ts b/tests/cases/conformance/types/intersection/intersectionThisTypes.ts new file mode 100644 index 00000000000..8819148dc9e --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionThisTypes.ts @@ -0,0 +1,40 @@ +interface Thing1 { + a: number; + self(): this; +} + +interface Thing2 { + b: number; + me(): this; +} + +type Thing3 = Thing1 & Thing2; +type Thing4 = Thing3 & string[]; + +function f1(t: Thing3) { + t = t.self(); + t = t.me().self().me(); +} + +interface Thing5 extends Thing4 { + c: string; +} + +function f2(t: Thing5) { + t = t.self(); + t = t.me().self().me(); +} + +interface Component { + extend(props: T): this & T; +} + +interface Label extends Component { + title: string; +} + +function test(label: Label) { + const extended = label.extend({ id: 67 }).extend({ tag: "hello" }); + extended.id; // Ok + extended.tag; // Ok +} From 3a34cb3088632f2361b7adafdb16fe802febcd8e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 21 Jan 2017 13:12:02 -0800 Subject: [PATCH 157/175] Accept new baselines --- .../interfaceExtendsObjectIntersection.js | 145 +++++++++++ ...interfaceExtendsObjectIntersection.symbols | 230 +++++++++++++++++ .../interfaceExtendsObjectIntersection.types | 242 ++++++++++++++++++ ...ExtendsObjectIntersectionErrors.errors.txt | 197 ++++++++++++++ ...nterfaceExtendsObjectIntersectionErrors.js | 97 +++++++ .../reference/intersectionThisTypes.js | 57 +++++ .../reference/intersectionThisTypes.symbols | 127 +++++++++ .../reference/intersectionThisTypes.types | 145 +++++++++++ 8 files changed, 1240 insertions(+) create mode 100644 tests/baselines/reference/interfaceExtendsObjectIntersection.js create mode 100644 tests/baselines/reference/interfaceExtendsObjectIntersection.symbols create mode 100644 tests/baselines/reference/interfaceExtendsObjectIntersection.types create mode 100644 tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt create mode 100644 tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.js create mode 100644 tests/baselines/reference/intersectionThisTypes.js create mode 100644 tests/baselines/reference/intersectionThisTypes.symbols create mode 100644 tests/baselines/reference/intersectionThisTypes.types diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.js b/tests/baselines/reference/interfaceExtendsObjectIntersection.js new file mode 100644 index 00000000000..a6fb62f5070 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.js @@ -0,0 +1,145 @@ +//// [interfaceExtendsObjectIntersection.ts] + +type T1 = { a: number }; +type T2 = T1 & { b: number }; +type T3 = () => void; +type T4 = new () => { a: number }; +type T5 = number[]; +type T6 = [string, number]; +type T7 = { [P in 'a' | 'b' | 'c']: string }; + +interface I1 extends T1 { x: string } +interface I2 extends T2 { x: string } +interface I3 extends T3 { x: string } +interface I4 extends T4 { x: string } +interface I5 extends T5 { x: string } +interface I6 extends T6 { x: string } +interface I7 extends T7 { x: string } + +type Constructor = new () => T; +declare function Constructor(): Constructor; + +class C1 extends Constructor() { x: string } +class C2 extends Constructor() { x: string } +class C3 extends Constructor() { x: string } +class C4 extends Constructor() { x: string } +class C5 extends Constructor() { x: string } +class C6 extends Constructor() { x: string } +class C7 extends Constructor() { x: string } + +declare function fx(x: string): string; +declare class CX { a: number } +declare enum EX { A, B, C } +declare namespace NX { export const a = 1 } + +type T10 = typeof fx; +type T11 = typeof CX; +type T12 = typeof EX; +type T13 = typeof NX; + +interface I10 extends T10 { x: string } +interface I11 extends T11 { x: string } +interface I12 extends T12 { x: string } +interface I13 extends T13 { x: string } + +type Identifiable = { _id: string } & T; + +interface I20 extends Partial { x: string } +interface I21 extends Readonly { x: string } +interface I22 extends Identifiable { x: string } +interface I23 extends Identifiable { x: string } + +class C20 extends Constructor>() { x: string } +class C21 extends Constructor>() { x: string } +class C22 extends Constructor>() { x: string } +class C23 extends Constructor>() { x: string } + + +//// [interfaceExtendsObjectIntersection.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C1; +}(Constructor())); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C2; +}(Constructor())); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C3; +}(Constructor())); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C4; +}(Constructor())); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C5; +}(Constructor())); +var C6 = (function (_super) { + __extends(C6, _super); + function C6() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C6; +}(Constructor())); +var C7 = (function (_super) { + __extends(C7, _super); + function C7() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C7; +}(Constructor())); +var C20 = (function (_super) { + __extends(C20, _super); + function C20() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C20; +}(Constructor())); +var C21 = (function (_super) { + __extends(C21, _super); + function C21() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C21; +}(Constructor())); +var C22 = (function (_super) { + __extends(C22, _super); + function C22() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C22; +}(Constructor())); +var C23 = (function (_super) { + __extends(C23, _super); + function C23() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C23; +}(Constructor())); diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.symbols b/tests/baselines/reference/interfaceExtendsObjectIntersection.symbols new file mode 100644 index 00000000000..16c8c51cf47 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.symbols @@ -0,0 +1,230 @@ +=== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts === + +type T1 = { a: number }; +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>a : Symbol(a, Decl(interfaceExtendsObjectIntersection.ts, 1, 11)) + +type T2 = T1 & { b: number }; +>T2 : Symbol(T2, Decl(interfaceExtendsObjectIntersection.ts, 1, 24)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>b : Symbol(b, Decl(interfaceExtendsObjectIntersection.ts, 2, 16)) + +type T3 = () => void; +>T3 : Symbol(T3, Decl(interfaceExtendsObjectIntersection.ts, 2, 29)) + +type T4 = new () => { a: number }; +>T4 : Symbol(T4, Decl(interfaceExtendsObjectIntersection.ts, 3, 21)) +>a : Symbol(a, Decl(interfaceExtendsObjectIntersection.ts, 4, 21)) + +type T5 = number[]; +>T5 : Symbol(T5, Decl(interfaceExtendsObjectIntersection.ts, 4, 34)) + +type T6 = [string, number]; +>T6 : Symbol(T6, Decl(interfaceExtendsObjectIntersection.ts, 5, 19)) + +type T7 = { [P in 'a' | 'b' | 'c']: string }; +>T7 : Symbol(T7, Decl(interfaceExtendsObjectIntersection.ts, 6, 27)) +>P : Symbol(P, Decl(interfaceExtendsObjectIntersection.ts, 7, 13)) + +interface I1 extends T1 { x: string } +>I1 : Symbol(I1, Decl(interfaceExtendsObjectIntersection.ts, 7, 45)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(I1.x, Decl(interfaceExtendsObjectIntersection.ts, 9, 25)) + +interface I2 extends T2 { x: string } +>I2 : Symbol(I2, Decl(interfaceExtendsObjectIntersection.ts, 9, 37)) +>T2 : Symbol(T2, Decl(interfaceExtendsObjectIntersection.ts, 1, 24)) +>x : Symbol(I2.x, Decl(interfaceExtendsObjectIntersection.ts, 10, 25)) + +interface I3 extends T3 { x: string } +>I3 : Symbol(I3, Decl(interfaceExtendsObjectIntersection.ts, 10, 37)) +>T3 : Symbol(T3, Decl(interfaceExtendsObjectIntersection.ts, 2, 29)) +>x : Symbol(I3.x, Decl(interfaceExtendsObjectIntersection.ts, 11, 25)) + +interface I4 extends T4 { x: string } +>I4 : Symbol(I4, Decl(interfaceExtendsObjectIntersection.ts, 11, 37)) +>T4 : Symbol(T4, Decl(interfaceExtendsObjectIntersection.ts, 3, 21)) +>x : Symbol(I4.x, Decl(interfaceExtendsObjectIntersection.ts, 12, 25)) + +interface I5 extends T5 { x: string } +>I5 : Symbol(I5, Decl(interfaceExtendsObjectIntersection.ts, 12, 37)) +>T5 : Symbol(T5, Decl(interfaceExtendsObjectIntersection.ts, 4, 34)) +>x : Symbol(I5.x, Decl(interfaceExtendsObjectIntersection.ts, 13, 25)) + +interface I6 extends T6 { x: string } +>I6 : Symbol(I6, Decl(interfaceExtendsObjectIntersection.ts, 13, 37)) +>T6 : Symbol(T6, Decl(interfaceExtendsObjectIntersection.ts, 5, 19)) +>x : Symbol(I6.x, Decl(interfaceExtendsObjectIntersection.ts, 14, 25)) + +interface I7 extends T7 { x: string } +>I7 : Symbol(I7, Decl(interfaceExtendsObjectIntersection.ts, 14, 37)) +>T7 : Symbol(T7, Decl(interfaceExtendsObjectIntersection.ts, 6, 27)) +>x : Symbol(I7.x, Decl(interfaceExtendsObjectIntersection.ts, 15, 25)) + +type Constructor = new () => T; +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 17, 17)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 17, 17)) + +declare function Constructor(): Constructor; +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 18, 29)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 18, 29)) + +class C1 extends Constructor() { x: string } +>C1 : Symbol(C1, Decl(interfaceExtendsObjectIntersection.ts, 18, 50)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I1 : Symbol(I1, Decl(interfaceExtendsObjectIntersection.ts, 7, 45)) +>x : Symbol(C1.x, Decl(interfaceExtendsObjectIntersection.ts, 20, 36)) + +class C2 extends Constructor() { x: string } +>C2 : Symbol(C2, Decl(interfaceExtendsObjectIntersection.ts, 20, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I2 : Symbol(I2, Decl(interfaceExtendsObjectIntersection.ts, 9, 37)) +>x : Symbol(C2.x, Decl(interfaceExtendsObjectIntersection.ts, 21, 36)) + +class C3 extends Constructor() { x: string } +>C3 : Symbol(C3, Decl(interfaceExtendsObjectIntersection.ts, 21, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I3 : Symbol(I3, Decl(interfaceExtendsObjectIntersection.ts, 10, 37)) +>x : Symbol(C3.x, Decl(interfaceExtendsObjectIntersection.ts, 22, 36)) + +class C4 extends Constructor() { x: string } +>C4 : Symbol(C4, Decl(interfaceExtendsObjectIntersection.ts, 22, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I4 : Symbol(I4, Decl(interfaceExtendsObjectIntersection.ts, 11, 37)) +>x : Symbol(C4.x, Decl(interfaceExtendsObjectIntersection.ts, 23, 36)) + +class C5 extends Constructor() { x: string } +>C5 : Symbol(C5, Decl(interfaceExtendsObjectIntersection.ts, 23, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I5 : Symbol(I5, Decl(interfaceExtendsObjectIntersection.ts, 12, 37)) +>x : Symbol(C5.x, Decl(interfaceExtendsObjectIntersection.ts, 24, 36)) + +class C6 extends Constructor() { x: string } +>C6 : Symbol(C6, Decl(interfaceExtendsObjectIntersection.ts, 24, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I6 : Symbol(I6, Decl(interfaceExtendsObjectIntersection.ts, 13, 37)) +>x : Symbol(C6.x, Decl(interfaceExtendsObjectIntersection.ts, 25, 36)) + +class C7 extends Constructor() { x: string } +>C7 : Symbol(C7, Decl(interfaceExtendsObjectIntersection.ts, 25, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I7 : Symbol(I7, Decl(interfaceExtendsObjectIntersection.ts, 14, 37)) +>x : Symbol(C7.x, Decl(interfaceExtendsObjectIntersection.ts, 26, 36)) + +declare function fx(x: string): string; +>fx : Symbol(fx, Decl(interfaceExtendsObjectIntersection.ts, 26, 48)) +>x : Symbol(x, Decl(interfaceExtendsObjectIntersection.ts, 28, 20)) + +declare class CX { a: number } +>CX : Symbol(CX, Decl(interfaceExtendsObjectIntersection.ts, 28, 39)) +>a : Symbol(CX.a, Decl(interfaceExtendsObjectIntersection.ts, 29, 18)) + +declare enum EX { A, B, C } +>EX : Symbol(EX, Decl(interfaceExtendsObjectIntersection.ts, 29, 30)) +>A : Symbol(EX.A, Decl(interfaceExtendsObjectIntersection.ts, 30, 17)) +>B : Symbol(EX.B, Decl(interfaceExtendsObjectIntersection.ts, 30, 20)) +>C : Symbol(EX.C, Decl(interfaceExtendsObjectIntersection.ts, 30, 23)) + +declare namespace NX { export const a = 1 } +>NX : Symbol(NX, Decl(interfaceExtendsObjectIntersection.ts, 30, 27)) +>a : Symbol(a, Decl(interfaceExtendsObjectIntersection.ts, 31, 35)) + +type T10 = typeof fx; +>T10 : Symbol(T10, Decl(interfaceExtendsObjectIntersection.ts, 31, 43)) +>fx : Symbol(fx, Decl(interfaceExtendsObjectIntersection.ts, 26, 48)) + +type T11 = typeof CX; +>T11 : Symbol(T11, Decl(interfaceExtendsObjectIntersection.ts, 33, 21)) +>CX : Symbol(CX, Decl(interfaceExtendsObjectIntersection.ts, 28, 39)) + +type T12 = typeof EX; +>T12 : Symbol(T12, Decl(interfaceExtendsObjectIntersection.ts, 34, 21)) +>EX : Symbol(EX, Decl(interfaceExtendsObjectIntersection.ts, 29, 30)) + +type T13 = typeof NX; +>T13 : Symbol(T13, Decl(interfaceExtendsObjectIntersection.ts, 35, 21)) +>NX : Symbol(NX, Decl(interfaceExtendsObjectIntersection.ts, 30, 27)) + +interface I10 extends T10 { x: string } +>I10 : Symbol(I10, Decl(interfaceExtendsObjectIntersection.ts, 36, 21)) +>T10 : Symbol(T10, Decl(interfaceExtendsObjectIntersection.ts, 31, 43)) +>x : Symbol(I10.x, Decl(interfaceExtendsObjectIntersection.ts, 38, 27)) + +interface I11 extends T11 { x: string } +>I11 : Symbol(I11, Decl(interfaceExtendsObjectIntersection.ts, 38, 39)) +>T11 : Symbol(T11, Decl(interfaceExtendsObjectIntersection.ts, 33, 21)) +>x : Symbol(I11.x, Decl(interfaceExtendsObjectIntersection.ts, 39, 27)) + +interface I12 extends T12 { x: string } +>I12 : Symbol(I12, Decl(interfaceExtendsObjectIntersection.ts, 39, 39)) +>T12 : Symbol(T12, Decl(interfaceExtendsObjectIntersection.ts, 34, 21)) +>x : Symbol(I12.x, Decl(interfaceExtendsObjectIntersection.ts, 40, 27)) + +interface I13 extends T13 { x: string } +>I13 : Symbol(I13, Decl(interfaceExtendsObjectIntersection.ts, 40, 39)) +>T13 : Symbol(T13, Decl(interfaceExtendsObjectIntersection.ts, 35, 21)) +>x : Symbol(I13.x, Decl(interfaceExtendsObjectIntersection.ts, 41, 27)) + +type Identifiable = { _id: string } & T; +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 43, 18)) +>_id : Symbol(_id, Decl(interfaceExtendsObjectIntersection.ts, 43, 24)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 43, 18)) + +interface I20 extends Partial { x: string } +>I20 : Symbol(I20, Decl(interfaceExtendsObjectIntersection.ts, 43, 43)) +>Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(I20.x, Decl(interfaceExtendsObjectIntersection.ts, 45, 35)) + +interface I21 extends Readonly { x: string } +>I21 : Symbol(I21, Decl(interfaceExtendsObjectIntersection.ts, 45, 47)) +>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(I21.x, Decl(interfaceExtendsObjectIntersection.ts, 46, 36)) + +interface I22 extends Identifiable { x: string } +>I22 : Symbol(I22, Decl(interfaceExtendsObjectIntersection.ts, 46, 48)) +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(I22.x, Decl(interfaceExtendsObjectIntersection.ts, 47, 40)) + +interface I23 extends Identifiable { x: string } +>I23 : Symbol(I23, Decl(interfaceExtendsObjectIntersection.ts, 47, 52)) +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>b : Symbol(b, Decl(interfaceExtendsObjectIntersection.ts, 48, 41)) +>x : Symbol(I23.x, Decl(interfaceExtendsObjectIntersection.ts, 48, 55)) + +class C20 extends Constructor>() { x: string } +>C20 : Symbol(C20, Decl(interfaceExtendsObjectIntersection.ts, 48, 67)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(C20.x, Decl(interfaceExtendsObjectIntersection.ts, 50, 46)) + +class C21 extends Constructor>() { x: string } +>C21 : Symbol(C21, Decl(interfaceExtendsObjectIntersection.ts, 50, 58)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(C21.x, Decl(interfaceExtendsObjectIntersection.ts, 51, 47)) + +class C22 extends Constructor>() { x: string } +>C22 : Symbol(C22, Decl(interfaceExtendsObjectIntersection.ts, 51, 59)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(C22.x, Decl(interfaceExtendsObjectIntersection.ts, 52, 51)) + +class C23 extends Constructor>() { x: string } +>C23 : Symbol(C23, Decl(interfaceExtendsObjectIntersection.ts, 52, 63)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>b : Symbol(b, Decl(interfaceExtendsObjectIntersection.ts, 53, 49)) +>x : Symbol(C23.x, Decl(interfaceExtendsObjectIntersection.ts, 53, 66)) + diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.types b/tests/baselines/reference/interfaceExtendsObjectIntersection.types new file mode 100644 index 00000000000..1ff550df7b4 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.types @@ -0,0 +1,242 @@ +=== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts === + +type T1 = { a: number }; +>T1 : T1 +>a : number + +type T2 = T1 & { b: number }; +>T2 : T2 +>T1 : T1 +>b : number + +type T3 = () => void; +>T3 : T3 + +type T4 = new () => { a: number }; +>T4 : T4 +>a : number + +type T5 = number[]; +>T5 : number[] + +type T6 = [string, number]; +>T6 : [string, number] + +type T7 = { [P in 'a' | 'b' | 'c']: string }; +>T7 : T7 +>P : P + +interface I1 extends T1 { x: string } +>I1 : I1 +>T1 : T1 +>x : string + +interface I2 extends T2 { x: string } +>I2 : I2 +>T2 : T2 +>x : string + +interface I3 extends T3 { x: string } +>I3 : I3 +>T3 : T3 +>x : string + +interface I4 extends T4 { x: string } +>I4 : I4 +>T4 : T4 +>x : string + +interface I5 extends T5 { x: string } +>I5 : I5 +>T5 : number[] +>x : string + +interface I6 extends T6 { x: string } +>I6 : I6 +>T6 : [string, number] +>x : string + +interface I7 extends T7 { x: string } +>I7 : I7 +>T7 : T7 +>x : string + +type Constructor = new () => T; +>Constructor : Constructor +>T : T +>T : T + +declare function Constructor(): Constructor; +>Constructor : () => Constructor +>T : T +>Constructor : Constructor +>T : T + +class C1 extends Constructor() { x: string } +>C1 : C1 +>Constructor() : I1 +>Constructor : () => Constructor +>I1 : I1 +>x : string + +class C2 extends Constructor() { x: string } +>C2 : C2 +>Constructor() : I2 +>Constructor : () => Constructor +>I2 : I2 +>x : string + +class C3 extends Constructor() { x: string } +>C3 : C3 +>Constructor() : I3 +>Constructor : () => Constructor +>I3 : I3 +>x : string + +class C4 extends Constructor() { x: string } +>C4 : C4 +>Constructor() : I4 +>Constructor : () => Constructor +>I4 : I4 +>x : string + +class C5 extends Constructor() { x: string } +>C5 : C5 +>Constructor() : I5 +>Constructor : () => Constructor +>I5 : I5 +>x : string + +class C6 extends Constructor() { x: string } +>C6 : C6 +>Constructor() : I6 +>Constructor : () => Constructor +>I6 : I6 +>x : string + +class C7 extends Constructor() { x: string } +>C7 : C7 +>Constructor() : I7 +>Constructor : () => Constructor +>I7 : I7 +>x : string + +declare function fx(x: string): string; +>fx : (x: string) => string +>x : string + +declare class CX { a: number } +>CX : CX +>a : number + +declare enum EX { A, B, C } +>EX : EX +>A : EX +>B : EX +>C : EX + +declare namespace NX { export const a = 1 } +>NX : typeof NX +>a : 1 +>1 : 1 + +type T10 = typeof fx; +>T10 : (x: string) => string +>fx : (x: string) => string + +type T11 = typeof CX; +>T11 : typeof CX +>CX : typeof CX + +type T12 = typeof EX; +>T12 : typeof EX +>EX : typeof EX + +type T13 = typeof NX; +>T13 : typeof NX +>NX : typeof NX + +interface I10 extends T10 { x: string } +>I10 : I10 +>T10 : (x: string) => string +>x : string + +interface I11 extends T11 { x: string } +>I11 : I11 +>T11 : typeof CX +>x : string + +interface I12 extends T12 { x: string } +>I12 : I12 +>T12 : typeof EX +>x : string + +interface I13 extends T13 { x: string } +>I13 : I13 +>T13 : typeof NX +>x : string + +type Identifiable = { _id: string } & T; +>Identifiable : Identifiable +>T : T +>_id : string +>T : T + +interface I20 extends Partial { x: string } +>I20 : I20 +>Partial : Partial +>T1 : T1 +>x : string + +interface I21 extends Readonly { x: string } +>I21 : I21 +>Readonly : Readonly +>T1 : T1 +>x : string + +interface I22 extends Identifiable { x: string } +>I22 : I22 +>Identifiable : Identifiable +>T1 : T1 +>x : string + +interface I23 extends Identifiable { x: string } +>I23 : I23 +>Identifiable : Identifiable +>T1 : T1 +>b : number +>x : string + +class C20 extends Constructor>() { x: string } +>C20 : C20 +>Constructor>() : Partial +>Constructor : () => Constructor +>Partial : Partial +>T1 : T1 +>x : string + +class C21 extends Constructor>() { x: string } +>C21 : C21 +>Constructor>() : Readonly +>Constructor : () => Constructor +>Readonly : Readonly +>T1 : T1 +>x : string + +class C22 extends Constructor>() { x: string } +>C22 : C22 +>Constructor>() : Identifiable +>Constructor : () => Constructor +>Identifiable : Identifiable +>T1 : T1 +>x : string + +class C23 extends Constructor>() { x: string } +>C23 : C23 +>Constructor>() : Identifiable +>Constructor : () => Constructor +>Identifiable : Identifiable +>T1 : T1 +>b : number +>x : string + diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt new file mode 100644 index 00000000000..839474b3bdc --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -0,0 +1,197 @@ +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(8,11): error TS2430: Interface 'I1' incorrectly extends interface 'T1'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(9,11): error TS2430: Interface 'I2' incorrectly extends interface 'T2'. + Type 'I2' is not assignable to type '{ b: number; }'. + Types of property 'b' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(10,11): error TS2430: Interface 'I3' incorrectly extends interface 'number[]'. + Types of property 'length' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(11,11): error TS2430: Interface 'I4' incorrectly extends interface '[string, number]'. + Types of property '0' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(12,11): error TS2430: Interface 'I5' incorrectly extends interface 'T5'. + Types of property 'c' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,7): error TS2415: Class 'C1' incorrectly extends base class 'T1'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(18,7): error TS2415: Class 'C2' incorrectly extends base class 'T2'. + Type 'C2' is not assignable to type '{ b: number; }'. + Types of property 'b' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,7): error TS2415: Class 'C3' incorrectly extends base class 'number[]'. + Types of property 'length' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,7): error TS2415: Class 'C4' incorrectly extends base class '[string, number]'. + Types of property '0' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(21,7): error TS2415: Class 'C5' incorrectly extends base class 'T5'. + Types of property 'c' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(31,11): error TS2430: Interface 'I10' incorrectly extends interface 'typeof CX'. + Types of property 'a' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(32,11): error TS2430: Interface 'I11' incorrectly extends interface 'typeof EX'. + Types of property 'C' are incompatible. + Type 'string' is not assignable to type 'EX'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(33,11): error TS2430: Interface 'I12' incorrectly extends interface 'typeof NX'. + Types of property 'a' are incompatible. + Type 'number' is not assignable to type '"hello"'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(34,29): error TS2411: Property 'a' of type 'string' is not assignable to string index type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(34,29): error TS2411: Property 'prototype' of type 'CX' is not assignable to string index type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(35,29): error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(36,29): error TS2411: Property 'a' of type '"hello"' is not assignable to string index type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(40,11): error TS2430: Interface 'I20' incorrectly extends interface 'Partial'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number | undefined'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(41,11): error TS2430: Interface 'I21' incorrectly extends interface 'Readonly'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(42,11): error TS2430: Interface 'I22' incorrectly extends interface 'Identifiable'. + Type 'I22' is not assignable to type 'T1'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(43,11): error TS2430: Interface 'I23' incorrectly extends interface 'Identifiable'. + Type 'I23' is not assignable to type 'T1'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(47,23): error TS2312: An interface may only extend a class or another interface. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(48,26): error TS2312: An interface may only extend a class or another interface. + + +==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (23 errors) ==== + + type T1 = { a: number }; + type T2 = T1 & { b: number }; + type T3 = number[]; + type T4 = [string, number]; + type T5 = { [P in 'a' | 'b' | 'c']: string }; + + interface I1 extends T1 { a: string } + ~~ +!!! error TS2430: Interface 'I1' incorrectly extends interface 'T1'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I2 extends T2 { b: string } + ~~ +!!! error TS2430: Interface 'I2' incorrectly extends interface 'T2'. +!!! error TS2430: Type 'I2' is not assignable to type '{ b: number; }'. +!!! error TS2430: Types of property 'b' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I3 extends T3 { length: string } + ~~ +!!! error TS2430: Interface 'I3' incorrectly extends interface 'number[]'. +!!! error TS2430: Types of property 'length' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I4 extends T4 { 0: number } + ~~ +!!! error TS2430: Interface 'I4' incorrectly extends interface '[string, number]'. +!!! error TS2430: Types of property '0' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. + interface I5 extends T5 { c: number } + ~~ +!!! error TS2430: Interface 'I5' incorrectly extends interface 'T5'. +!!! error TS2430: Types of property 'c' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. + + type Constructor = new () => T; + declare function Constructor(): Constructor; + + class C1 extends Constructor() { a: string } + ~~ +!!! error TS2415: Class 'C1' incorrectly extends base class 'T1'. +!!! error TS2415: Types of property 'a' are incompatible. +!!! error TS2415: Type 'string' is not assignable to type 'number'. + class C2 extends Constructor() { b: string } + ~~ +!!! error TS2415: Class 'C2' incorrectly extends base class 'T2'. +!!! error TS2415: Type 'C2' is not assignable to type '{ b: number; }'. +!!! error TS2415: Types of property 'b' are incompatible. +!!! error TS2415: Type 'string' is not assignable to type 'number'. + class C3 extends Constructor() { length: string } + ~~ +!!! error TS2415: Class 'C3' incorrectly extends base class 'number[]'. +!!! error TS2415: Types of property 'length' are incompatible. +!!! error TS2415: Type 'string' is not assignable to type 'number'. + class C4 extends Constructor() { 0: number } + ~~ +!!! error TS2415: Class 'C4' incorrectly extends base class '[string, number]'. +!!! error TS2415: Types of property '0' are incompatible. +!!! error TS2415: Type 'number' is not assignable to type 'string'. + class C5 extends Constructor() { c: number } + ~~ +!!! error TS2415: Class 'C5' incorrectly extends base class 'T5'. +!!! error TS2415: Types of property 'c' are incompatible. +!!! error TS2415: Type 'number' is not assignable to type 'string'. + + declare class CX { static a: string } + declare enum EX { A, B, C } + declare namespace NX { export const a = "hello" } + + type TCX = typeof CX; + type TEX = typeof EX; + type TNX = typeof NX; + + interface I10 extends TCX { a: number } + ~~~ +!!! error TS2430: Interface 'I10' incorrectly extends interface 'typeof CX'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. + interface I11 extends TEX { C: string } + ~~~ +!!! error TS2430: Interface 'I11' incorrectly extends interface 'typeof EX'. +!!! error TS2430: Types of property 'C' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'EX'. + interface I12 extends TNX { a: number } + ~~~ +!!! error TS2430: Interface 'I12' incorrectly extends interface 'typeof NX'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type '"hello"'. + interface I14 extends TCX { [x: string]: number } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2411: Property 'a' of type 'string' is not assignable to string index type 'number'. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2411: Property 'prototype' of type 'CX' is not assignable to string index type 'number'. + interface I15 extends TEX { [x: string]: number } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. + interface I16 extends TNX { [x: string]: number } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2411: Property 'a' of type '"hello"' is not assignable to string index type 'number'. + + type Identifiable = { _id: string } & T; + + interface I20 extends Partial { a: string } + ~~~ +!!! error TS2430: Interface 'I20' incorrectly extends interface 'Partial'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number | undefined'. + interface I21 extends Readonly { a: string } + ~~~ +!!! error TS2430: Interface 'I21' incorrectly extends interface 'Readonly'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I22 extends Identifiable { a: string } + ~~~ +!!! error TS2430: Interface 'I22' incorrectly extends interface 'Identifiable'. +!!! error TS2430: Type 'I22' is not assignable to type 'T1'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I23 extends Identifiable { a: string } + ~~~ +!!! error TS2430: Interface 'I23' incorrectly extends interface 'Identifiable'. +!!! error TS2430: Type 'I23' is not assignable to type 'T1'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + + type U = { a: number } | { b: string }; + + interface I30 extends U { x: string } + ~ +!!! error TS2312: An interface may only extend a class or another interface. + interface I31 extends T { x: string } + ~ +!!! error TS2312: An interface may only extend a class or another interface. + \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.js b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.js new file mode 100644 index 00000000000..61f84b2f7fe --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.js @@ -0,0 +1,97 @@ +//// [interfaceExtendsObjectIntersectionErrors.ts] + +type T1 = { a: number }; +type T2 = T1 & { b: number }; +type T3 = number[]; +type T4 = [string, number]; +type T5 = { [P in 'a' | 'b' | 'c']: string }; + +interface I1 extends T1 { a: string } +interface I2 extends T2 { b: string } +interface I3 extends T3 { length: string } +interface I4 extends T4 { 0: number } +interface I5 extends T5 { c: number } + +type Constructor = new () => T; +declare function Constructor(): Constructor; + +class C1 extends Constructor() { a: string } +class C2 extends Constructor() { b: string } +class C3 extends Constructor() { length: string } +class C4 extends Constructor() { 0: number } +class C5 extends Constructor() { c: number } + +declare class CX { static a: string } +declare enum EX { A, B, C } +declare namespace NX { export const a = "hello" } + +type TCX = typeof CX; +type TEX = typeof EX; +type TNX = typeof NX; + +interface I10 extends TCX { a: number } +interface I11 extends TEX { C: string } +interface I12 extends TNX { a: number } +interface I14 extends TCX { [x: string]: number } +interface I15 extends TEX { [x: string]: number } +interface I16 extends TNX { [x: string]: number } + +type Identifiable = { _id: string } & T; + +interface I20 extends Partial { a: string } +interface I21 extends Readonly { a: string } +interface I22 extends Identifiable { a: string } +interface I23 extends Identifiable { a: string } + +type U = { a: number } | { b: string }; + +interface I30 extends U { x: string } +interface I31 extends T { x: string } + + +//// [interfaceExtendsObjectIntersectionErrors.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C1; +}(Constructor())); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C2; +}(Constructor())); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C3; +}(Constructor())); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C4; +}(Constructor())); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C5; +}(Constructor())); diff --git a/tests/baselines/reference/intersectionThisTypes.js b/tests/baselines/reference/intersectionThisTypes.js new file mode 100644 index 00000000000..9c7be09eeb8 --- /dev/null +++ b/tests/baselines/reference/intersectionThisTypes.js @@ -0,0 +1,57 @@ +//// [intersectionThisTypes.ts] +interface Thing1 { + a: number; + self(): this; +} + +interface Thing2 { + b: number; + me(): this; +} + +type Thing3 = Thing1 & Thing2; +type Thing4 = Thing3 & string[]; + +function f1(t: Thing3) { + t = t.self(); + t = t.me().self().me(); +} + +interface Thing5 extends Thing4 { + c: string; +} + +function f2(t: Thing5) { + t = t.self(); + t = t.me().self().me(); +} + +interface Component { + extend(props: T): this & T; +} + +interface Label extends Component { + title: string; +} + +function test(label: Label) { + const extended = label.extend({ id: 67 }).extend({ tag: "hello" }); + extended.id; // Ok + extended.tag; // Ok +} + + +//// [intersectionThisTypes.js] +function f1(t) { + t = t.self(); + t = t.me().self().me(); +} +function f2(t) { + t = t.self(); + t = t.me().self().me(); +} +function test(label) { + var extended = label.extend({ id: 67 }).extend({ tag: "hello" }); + extended.id; // Ok + extended.tag; // Ok +} diff --git a/tests/baselines/reference/intersectionThisTypes.symbols b/tests/baselines/reference/intersectionThisTypes.symbols new file mode 100644 index 00000000000..8a8a6cd5496 --- /dev/null +++ b/tests/baselines/reference/intersectionThisTypes.symbols @@ -0,0 +1,127 @@ +=== tests/cases/conformance/types/intersection/intersectionThisTypes.ts === +interface Thing1 { +>Thing1 : Symbol(Thing1, Decl(intersectionThisTypes.ts, 0, 0)) + + a: number; +>a : Symbol(Thing1.a, Decl(intersectionThisTypes.ts, 0, 18)) + + self(): this; +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +} + +interface Thing2 { +>Thing2 : Symbol(Thing2, Decl(intersectionThisTypes.ts, 3, 1)) + + b: number; +>b : Symbol(Thing2.b, Decl(intersectionThisTypes.ts, 5, 18)) + + me(): this; +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +} + +type Thing3 = Thing1 & Thing2; +>Thing3 : Symbol(Thing3, Decl(intersectionThisTypes.ts, 8, 1)) +>Thing1 : Symbol(Thing1, Decl(intersectionThisTypes.ts, 0, 0)) +>Thing2 : Symbol(Thing2, Decl(intersectionThisTypes.ts, 3, 1)) + +type Thing4 = Thing3 & string[]; +>Thing4 : Symbol(Thing4, Decl(intersectionThisTypes.ts, 10, 30)) +>Thing3 : Symbol(Thing3, Decl(intersectionThisTypes.ts, 8, 1)) + +function f1(t: Thing3) { +>f1 : Symbol(f1, Decl(intersectionThisTypes.ts, 11, 32)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>Thing3 : Symbol(Thing3, Decl(intersectionThisTypes.ts, 8, 1)) + + t = t.self(); +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>t.self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) + + t = t.me().self().me(); +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>t.me().self().me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>t.me().self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>t.me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +} + +interface Thing5 extends Thing4 { +>Thing5 : Symbol(Thing5, Decl(intersectionThisTypes.ts, 16, 1)) +>Thing4 : Symbol(Thing4, Decl(intersectionThisTypes.ts, 10, 30)) + + c: string; +>c : Symbol(Thing5.c, Decl(intersectionThisTypes.ts, 18, 33)) +} + +function f2(t: Thing5) { +>f2 : Symbol(f2, Decl(intersectionThisTypes.ts, 20, 1)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>Thing5 : Symbol(Thing5, Decl(intersectionThisTypes.ts, 16, 1)) + + t = t.self(); +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>t.self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) + + t = t.me().self().me(); +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>t.me().self().me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>t.me().self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>t.me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +} + +interface Component { +>Component : Symbol(Component, Decl(intersectionThisTypes.ts, 25, 1)) + + extend(props: T): this & T; +>extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>T : Symbol(T, Decl(intersectionThisTypes.ts, 28, 11)) +>props : Symbol(props, Decl(intersectionThisTypes.ts, 28, 14)) +>T : Symbol(T, Decl(intersectionThisTypes.ts, 28, 11)) +>T : Symbol(T, Decl(intersectionThisTypes.ts, 28, 11)) +} + +interface Label extends Component { +>Label : Symbol(Label, Decl(intersectionThisTypes.ts, 29, 1)) +>Component : Symbol(Component, Decl(intersectionThisTypes.ts, 25, 1)) + + title: string; +>title : Symbol(Label.title, Decl(intersectionThisTypes.ts, 31, 35)) +} + +function test(label: Label) { +>test : Symbol(test, Decl(intersectionThisTypes.ts, 33, 1)) +>label : Symbol(label, Decl(intersectionThisTypes.ts, 35, 14)) +>Label : Symbol(Label, Decl(intersectionThisTypes.ts, 29, 1)) + + const extended = label.extend({ id: 67 }).extend({ tag: "hello" }); +>extended : Symbol(extended, Decl(intersectionThisTypes.ts, 36, 9)) +>label.extend({ id: 67 }).extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>label.extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>label : Symbol(label, Decl(intersectionThisTypes.ts, 35, 14)) +>extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>id : Symbol(id, Decl(intersectionThisTypes.ts, 36, 35)) +>extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>tag : Symbol(tag, Decl(intersectionThisTypes.ts, 36, 54)) + + extended.id; // Ok +>extended.id : Symbol(id, Decl(intersectionThisTypes.ts, 36, 35)) +>extended : Symbol(extended, Decl(intersectionThisTypes.ts, 36, 9)) +>id : Symbol(id, Decl(intersectionThisTypes.ts, 36, 35)) + + extended.tag; // Ok +>extended.tag : Symbol(tag, Decl(intersectionThisTypes.ts, 36, 54)) +>extended : Symbol(extended, Decl(intersectionThisTypes.ts, 36, 9)) +>tag : Symbol(tag, Decl(intersectionThisTypes.ts, 36, 54)) +} + diff --git a/tests/baselines/reference/intersectionThisTypes.types b/tests/baselines/reference/intersectionThisTypes.types new file mode 100644 index 00000000000..285609cdfdc --- /dev/null +++ b/tests/baselines/reference/intersectionThisTypes.types @@ -0,0 +1,145 @@ +=== tests/cases/conformance/types/intersection/intersectionThisTypes.ts === +interface Thing1 { +>Thing1 : Thing1 + + a: number; +>a : number + + self(): this; +>self : () => this +} + +interface Thing2 { +>Thing2 : Thing2 + + b: number; +>b : number + + me(): this; +>me : () => this +} + +type Thing3 = Thing1 & Thing2; +>Thing3 : Thing3 +>Thing1 : Thing1 +>Thing2 : Thing2 + +type Thing4 = Thing3 & string[]; +>Thing4 : Thing4 +>Thing3 : Thing3 + +function f1(t: Thing3) { +>f1 : (t: Thing3) => void +>t : Thing3 +>Thing3 : Thing3 + + t = t.self(); +>t = t.self() : Thing3 +>t : Thing3 +>t.self() : Thing3 +>t.self : () => Thing3 +>t : Thing3 +>self : () => Thing3 + + t = t.me().self().me(); +>t = t.me().self().me() : Thing3 +>t : Thing3 +>t.me().self().me() : Thing3 +>t.me().self().me : () => Thing3 +>t.me().self() : Thing3 +>t.me().self : () => Thing3 +>t.me() : Thing3 +>t.me : () => Thing3 +>t : Thing3 +>me : () => Thing3 +>self : () => Thing3 +>me : () => Thing3 +} + +interface Thing5 extends Thing4 { +>Thing5 : Thing5 +>Thing4 : Thing4 + + c: string; +>c : string +} + +function f2(t: Thing5) { +>f2 : (t: Thing5) => void +>t : Thing5 +>Thing5 : Thing5 + + t = t.self(); +>t = t.self() : Thing5 +>t : Thing5 +>t.self() : Thing5 +>t.self : () => Thing5 +>t : Thing5 +>self : () => Thing5 + + t = t.me().self().me(); +>t = t.me().self().me() : Thing5 +>t : Thing5 +>t.me().self().me() : Thing5 +>t.me().self().me : () => Thing5 +>t.me().self() : Thing5 +>t.me().self : () => Thing5 +>t.me() : Thing5 +>t.me : () => Thing5 +>t : Thing5 +>me : () => Thing5 +>self : () => Thing5 +>me : () => Thing5 +} + +interface Component { +>Component : Component + + extend(props: T): this & T; +>extend : (props: T) => this & T +>T : T +>props : T +>T : T +>T : T +} + +interface Label extends Component { +>Label : Label +>Component : Component + + title: string; +>title : string +} + +function test(label: Label) { +>test : (label: Label) => void +>label : Label +>Label : Label + + const extended = label.extend({ id: 67 }).extend({ tag: "hello" }); +>extended : Label & { id: number; } & { tag: string; } +>label.extend({ id: 67 }).extend({ tag: "hello" }) : Label & { id: number; } & { tag: string; } +>label.extend({ id: 67 }).extend : (props: T) => Label & { id: number; } & T +>label.extend({ id: 67 }) : Label & { id: number; } +>label.extend : (props: T) => Label & T +>label : Label +>extend : (props: T) => Label & T +>{ id: 67 } : { id: number; } +>id : number +>67 : 67 +>extend : (props: T) => Label & { id: number; } & T +>{ tag: "hello" } : { tag: string; } +>tag : string +>"hello" : "hello" + + extended.id; // Ok +>extended.id : number +>extended : Label & { id: number; } & { tag: string; } +>id : number + + extended.tag; // Ok +>extended.tag : string +>extended : Label & { id: number; } & { tag: string; } +>tag : string +} + From 80e5f2f314b46e327567902a912b2d885e6a4e63 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 22 Jan 2017 11:53:18 -0800 Subject: [PATCH 158/175] Add regression test --- .../conformance/types/keyof/keyofAndIndexedAccess.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts index a4088e65df4..04c26fbe8f7 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts @@ -505,3 +505,15 @@ function updateIds2( // Repro from #13514 declare function head>(list: T): T[0]; + +// Repro from #13604 + +class A { + props: T & { foo: string }; +} + +class B extends A<{ x: number}> { + f(p: this["props"]) { + p.x; + } +} From 6d6b19fd23e7795da5e73c4fe72517d898536b22 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 22 Jan 2017 11:54:39 -0800 Subject: [PATCH 159/175] Fix typo in intersection apparent type --- 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 60d109d7600..bd8ff7568f3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4871,7 +4871,7 @@ namespace ts { */ function getApparentType(type: Type): Type { const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfType(type) || emptyObjectType : type; - return t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(type) : + return t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t) : t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : From f0e90c0d8bcc0009dca5e4ffcbcbb9b529779f03 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 22 Jan 2017 11:59:40 -0800 Subject: [PATCH 160/175] Accept new baselines --- .../reference/keyofAndIndexedAccess.js | 38 +++++++++++++++++++ .../reference/keyofAndIndexedAccess.symbols | 28 ++++++++++++++ .../reference/keyofAndIndexedAccess.types | 28 ++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.js b/tests/baselines/reference/keyofAndIndexedAccess.js index a86184c8ff0..e7df8bbd5a1 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.js +++ b/tests/baselines/reference/keyofAndIndexedAccess.js @@ -504,6 +504,18 @@ function updateIds2( // Repro from #13514 declare function head>(list: T): T[0]; + +// Repro from #13604 + +class A { + props: T & { foo: string }; +} + +class B extends A<{ x: number}> { + f(p: this["props"]) { + p.x; + } +} //// [keyofAndIndexedAccess.js] @@ -834,6 +846,22 @@ function updateIds2(obj, key, stringMap) { var x = obj[key]; stringMap[x]; // Should be OK. } +// Repro from #13604 +var A = (function () { + function A() { + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B() { + return _super !== null && _super.apply(this, arguments) || this; + } + B.prototype.f = function (p) { + p.x; + }; + return B; +}(A)); //// [keyofAndIndexedAccess.d.ts] @@ -1066,3 +1094,13 @@ declare function updateIds2>(list: T): T[0]; +declare class A { + props: T & { + foo: string; + }; +} +declare class B extends A<{ + x: number; +}> { + f(p: this["props"]): void; +} diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index 4c12c6554c9..01501cd719c 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -1816,3 +1816,31 @@ declare function head>(list: T): T[0]; >T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 504, 22)) >T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 504, 22)) +// Repro from #13604 + +class A { +>A : Symbol(A, Decl(keyofAndIndexedAccess.ts, 504, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 508, 8)) + + props: T & { foo: string }; +>props : Symbol(A.props, Decl(keyofAndIndexedAccess.ts, 508, 12)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 508, 8)) +>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 509, 13)) +} + +class B extends A<{ x: number}> { +>B : Symbol(B, Decl(keyofAndIndexedAccess.ts, 510, 1)) +>A : Symbol(A, Decl(keyofAndIndexedAccess.ts, 504, 59)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 512, 19)) + + f(p: this["props"]) { +>f : Symbol(B.f, Decl(keyofAndIndexedAccess.ts, 512, 33)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 513, 3)) + + p.x; +>p.x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 512, 19)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 513, 3)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 512, 19)) + } +} + diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 3919d768151..21c9d645ce4 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -2138,3 +2138,31 @@ declare function head>(list: T): T[0]; >T : T >T : T +// Repro from #13604 + +class A { +>A : A +>T : T + + props: T & { foo: string }; +>props : T & { foo: string; } +>T : T +>foo : string +} + +class B extends A<{ x: number}> { +>B : B +>A : A<{ x: number; }> +>x : number + + f(p: this["props"]) { +>f : (p: this["props"]) => void +>p : this["props"] + + p.x; +>p.x : number +>p : this["props"] +>x : number + } +} + From dd0ed44b9aaa7dcd24bb415a5a6a241cd2d6061f Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Mon, 23 Jan 2017 17:40:20 +0100 Subject: [PATCH 161/175] Add option to output .js files while preserving jsx This commit adds the ability to preserve jsx in source code, but also to output .js files rather than .jsx files. This is useful for react-native which does not support .jsx files. --- lib/protocol.d.ts | 5 +- src/compiler/commandLineParser.ts | 3 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/types.ts | 3 +- src/harness/unittests/commandLineParsing.ts | 2 +- .../convertCompilerOptionsFromJson.ts | 2 +- src/harness/unittests/matchFiles.ts | 54 ++++++++++++++++- src/server/protocol.ts | 9 +-- tests/cases/unittests/matchFiles.ts | 58 ++++++++++++++++++- 9 files changed, 125 insertions(+), 13 deletions(-) diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index d6c0246af34..66c2ef5c8db 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1798,9 +1798,10 @@ declare namespace ts.server.protocol { namespace JsxEmit { type None = "None"; type Preserve = "Preserve"; + type PreserveWithJsExtension = "PreserveWithJsExtension"; type React = "React"; } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.PreserveWithJsExtension; namespace ModuleKind { type None = "None"; type CommonJS = "CommonJS"; @@ -1880,4 +1881,4 @@ declare namespace ts { } import protocol = ts.server.protocol; export = protocol; -export as namespace protocol; \ No newline at end of file +export as namespace protocol; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b222df53630..7c69676d6f0 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -67,10 +67,11 @@ namespace ts { name: "jsx", type: createMapFromTemplate({ "preserve": JsxEmit.Preserve, + "preservewithjsextension": JsxEmit.PreserveWithJsExtension, "react": JsxEmit.React }), paramType: Diagnostics.KIND, - description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_preserveWithJsExtension_or_react, }, { name: "reactNamespace", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 43bb7415c88..6646017e73d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2713,7 +2713,7 @@ "category": "Message", "code": 6079 }, - "Specify JSX code generation: 'preserve' or 'react'": { + "Specify JSX code generation: 'preserve', 'preserveWithJsExtension', or 'react'": { "category": "Message", "code": 6080 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c16c199d3eb..9024b7c1b13 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3298,7 +3298,8 @@ export const enum JsxEmit { None = 0, Preserve = 1, - React = 2 + React = 2, + PreserveWithJsExtension = 3 } export const enum NewLineKind { diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 8c691992043..34a096628f9 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -87,7 +87,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--jsx' option must be: 'preserve', 'react'", + messageText: "Argument for '--jsx' option must be: 'preserve', 'preservewithjsextension', 'react'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index f44dc259710..cbfa47180f3 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -94,7 +94,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--jsx' option must be: 'preserve', 'react'", + messageText: "Argument for '--jsx' option must be: 'preserve', 'preservewithjsextension', 'react'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/src/harness/unittests/matchFiles.ts b/src/harness/unittests/matchFiles.ts index c562fcefe91..2b4bbfd4ee6 100644 --- a/src/harness/unittests/matchFiles.ts +++ b/src/harness/unittests/matchFiles.ts @@ -909,6 +909,31 @@ namespace ts { const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); assertParsed(actual, expected); }); + it("with jsx=preserveWithJsExtension, allowJs=false", () => { + const json = { + compilerOptions: { + jsx: "preserveWithJsExtension", + allowJs: false + } + }; + const expected: ts.ParsedCommandLine = { + options: { + jsx: ts.JsxEmit.PreserveWithJsExtension, + allowJs: false + }, + errors: [], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/b.tsx", + "c:/dev/c.tsx", + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); + assertParsed(actual, expected); + }); it("with jsx=none, allowJs=true", () => { const json = { compilerOptions: { @@ -961,6 +986,33 @@ namespace ts { const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); assertParsed(actual, expected); }); + it("with jsx=preserveWithJsExtension, allowJs=true", () => { + const json = { + compilerOptions: { + jsx: "preserveWithJsExtension", + allowJs: true + } + }; + const expected: ts.ParsedCommandLine = { + options: { + jsx: ts.JsxEmit.PreserveWithJsExtension, + allowJs: true + }, + errors: [], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/b.tsx", + "c:/dev/c.tsx", + "c:/dev/d.js", + "c:/dev/e.jsx", + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); + assertParsed(actual, expected); + }); it("exclude .min.js files using wildcards", () => { const json = { compilerOptions: { @@ -1306,4 +1358,4 @@ namespace ts { }); }); }); -} \ No newline at end of file +} diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 680b81dff99..b18c887126b 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -417,7 +417,7 @@ namespace ts.server.protocol { startOffset: number; /** - * Position (can be specified instead of line/offset pair) + * Position (can be specified instead of line/offset pair) */ /* @internal */ startPosition?: number; @@ -433,7 +433,7 @@ namespace ts.server.protocol { endOffset: number; /** - * Position (can be specified instead of line/offset pair) + * Position (can be specified instead of line/offset pair) */ /* @internal */ endPosition?: number; @@ -445,7 +445,7 @@ namespace ts.server.protocol { } /** - * Response for GetCodeFixes request. + * Response for GetCodeFixes request. */ export interface GetCodeFixesResponse extends Response { body?: CodeAction[]; @@ -2272,10 +2272,11 @@ namespace ts.server.protocol { export namespace JsxEmit { export type None = "None"; export type Preserve = "Preserve"; + export type PreserveWithJsExtension = "PreserveWithJsExtension"; export type React = "React"; } - export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.PreserveWithJsExtension; export namespace ModuleKind { export type None = "None"; diff --git a/tests/cases/unittests/matchFiles.ts b/tests/cases/unittests/matchFiles.ts index 91be2de8747..ef982f5f2bb 100644 --- a/tests/cases/unittests/matchFiles.ts +++ b/tests/cases/unittests/matchFiles.ts @@ -898,6 +898,33 @@ namespace ts { assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); }); + it("with jsx=preserveWithJsExtension, allowJs=false", () => { + const json = { + compilerOptions: { + jsx: "preserveWithJsExtension", + allowJs: false + } + }; + const expected: ts.ParsedCommandLine = { + options: { + jsx: ts.JsxEmit.PreserveWithJsExtension, + allowJs: false + }, + errors: [], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/b.tsx", + "c:/dev/c.tsx", + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); it("with jsx=none, allowJs=true", () => { const json = { compilerOptions: { @@ -954,6 +981,35 @@ namespace ts { assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); }); + it("with jsx=preserveWithJsExtension, allowJs=true", () => { + const json = { + compilerOptions: { + jsx: "preserveWithJsExtension", + allowJs: true + } + }; + const expected: ts.ParsedCommandLine = { + options: { + jsx: ts.JsxEmit.PreserveWithJsExtension, + allowJs: true + }, + errors: [], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/b.tsx", + "c:/dev/c.tsx", + "c:/dev/d.js", + "c:/dev/e.jsx", + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); describe("with trailing recursive directory", () => { it("in includes", () => { const json = { @@ -1149,4 +1205,4 @@ namespace ts { }); }); }); -} \ No newline at end of file +} From 7879b22ea9b210934c50b8d87df418379dfcc435 Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Mon, 23 Jan 2017 19:30:24 +0100 Subject: [PATCH 162/175] Add test case for preserveWithJsExtension --- ...utTsxFile_PreserveWithJsExtension.baseline | 26 +++++++++++++++++++ ...itOutputTsxFile_PreserveWithJsExtension.ts | 22 ++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/baselines/reference/getEmitOutputTsxFile_PreserveWithJsExtension.baseline create mode 100644 tests/cases/fourslash/getEmitOutputTsxFile_PreserveWithJsExtension.ts diff --git a/tests/baselines/reference/getEmitOutputTsxFile_PreserveWithJsExtension.baseline b/tests/baselines/reference/getEmitOutputTsxFile_PreserveWithJsExtension.baseline new file mode 100644 index 00000000000..88fb0f0daf6 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputTsxFile_PreserveWithJsExtension.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : /tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js +// regular ts file +var t = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +}()); +//# sourceMappingURL=inputFile1.js.mapFileName : /tests/cases/fourslash/inputFile1.d.ts +declare var t: number; +declare class Bar { + x: string; + y: number; +} + +EmitSkipped: false +FileName : /tests/cases/fourslash/inputFile2.js.map +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : /tests/cases/fourslash/inputFile2.js +var y = "my div"; +var x =
; +//# sourceMappingURL=inputFile2.js.mapFileName : /tests/cases/fourslash/inputFile2.d.ts +declare var y: string; +declare var x: any; + diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_PreserveWithJsExtension.ts b/tests/cases/fourslash/getEmitOutputTsxFile_PreserveWithJsExtension.ts new file mode 100644 index 00000000000..a1e4ce2d984 --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputTsxFile_PreserveWithJsExtension.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputTsxFile_PreserveWithJsExtension.baseline +// @declaration: true +// @sourceMap: true +// @jsx: preserveWithJsExtension + +// @Filename: inputFile1.ts +// @emitThisFile: true +////// regular ts file +//// var t: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.tsx +// @emitThisFile: true +//// var y = "my div"; +//// var x =
+ +verify.baselineGetEmitOutput(); From a32914f6872b9c5764d77f77ea85c7160ff9ae28 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 23 Jan 2017 11:14:29 -0800 Subject: [PATCH 163/175] Combine `forEachExpectedEmitFile` and `forEachEmittedFile` --- src/compiler/declarationEmitter.ts | 4 ++-- src/compiler/emitter.ts | 2 +- src/compiler/program.ts | 2 +- src/compiler/utilities.ts | 24 ++++++++---------------- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 2287de179e3..46df4fed689 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -32,7 +32,7 @@ namespace ts { export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] { const declarationDiagnostics = createDiagnosticCollection(); - forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); function getDeclarationDiagnosticsFromFile({ declarationFilePath }: EmitFileNames, sources: SourceFile[], isBundledEmit: boolean) { @@ -1788,7 +1788,7 @@ namespace ts { } else { // Get the declaration file path - forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1c4662fa587..cc006a06637 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -73,7 +73,7 @@ namespace ts { // Emit each output file performance.mark("beforePrint"); - forEachEmittedFile(host, transformed, emitFile, emitOnlyDtsFiles); + forEachEmittedFile(host, emitFile, transformed, emitOnlyDtsFiles); performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 851e206d448..650711afc79 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1707,7 +1707,7 @@ namespace ts { if (!options.noEmit && !options.suppressOutputPathCheck) { const emitHost = getEmitHost(); const emitFilesSeen = createFileMap(!host.useCaseSensitiveFileNames() ? key => key.toLocaleLowerCase() : undefined); - forEachExpectedEmitFile(emitHost, (emitFileNames) => { + forEachEmittedFile(emitHost, (emitFileNames) => { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen); }); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f59d384e490..b7cc0f0de6d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2590,27 +2590,20 @@ namespace ts { } /** - * Iterates over the source files that are expected to have an emit output. This function - * is used by the legacy emitter and the declaration emitter and should not be used by - * the tree transforming emitter. + * Iterates over the source files that are expected to have an emit output. * * @param host An EmitHost. * @param action The action to execute. - * @param targetSourceFile An optional target source file to emit. + * @param sourceFilesOrTargetSourceFile + * If an array, the full list of source files to emit. + * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - export function forEachExpectedEmitFile(host: EmitHost, - action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, - targetSourceFile?: SourceFile, + export function forEachEmittedFile( + host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, + sourceFilesOrTargetSourceFile?: SourceFile[] | SourceFile, emitOnlyDtsFiles?: boolean) { - forEachEmittedFile(host, getSourceFilesToEmit(host, targetSourceFile), action, emitOnlyDtsFiles); - } - /** - * Iterates over each source file to emit. - */ - export function forEachEmittedFile(host: EmitHost, sourceFiles: SourceFile[], - action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, - emitOnlyDtsFiles?: boolean) { + const sourceFiles = isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); const options = host.getCompilerOptions(); if (options.outFile || options.out) { if (sourceFiles.length) { @@ -2622,7 +2615,6 @@ namespace ts { } else { for (const sourceFile of sourceFiles) { - const options = host.getCompilerOptions(); const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); const declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; From 8d590d51916e6491191634097b8fb04f40d7d964 Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Mon, 23 Jan 2017 21:42:39 +0100 Subject: [PATCH 164/175] rename preserveWithJsExtension to react-native --- lib/protocol.d.ts | 4 ++-- src/compiler/commandLineParser.ts | 4 ++-- src/compiler/diagnosticMessages.json | 2 +- src/compiler/types.ts | 2 +- src/harness/unittests/commandLineParsing.ts | 2 +- .../unittests/convertCompilerOptionsFromJson.ts | 2 +- src/harness/unittests/matchFiles.ts | 12 ++++++------ src/server/protocol.ts | 4 ++-- ...ine => getEmitOutputTsxFile_ReactNative.baseline} | 0 ...ension.ts => getEmitOutputTsxFile_ReactNative.ts} | 4 ++-- tests/cases/unittests/matchFiles.ts | 12 ++++++------ 11 files changed, 24 insertions(+), 24 deletions(-) rename tests/baselines/reference/{getEmitOutputTsxFile_PreserveWithJsExtension.baseline => getEmitOutputTsxFile_ReactNative.baseline} (100%) rename tests/cases/fourslash/{getEmitOutputTsxFile_PreserveWithJsExtension.ts => getEmitOutputTsxFile_ReactNative.ts} (75%) diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index 66c2ef5c8db..cd46ebcd366 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1798,10 +1798,10 @@ declare namespace ts.server.protocol { namespace JsxEmit { type None = "None"; type Preserve = "Preserve"; - type PreserveWithJsExtension = "PreserveWithJsExtension"; + type ReactNative = "ReactNative"; type React = "React"; } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.PreserveWithJsExtension; + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; namespace ModuleKind { type None = "None"; type CommonJS = "CommonJS"; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7c69676d6f0..248726693c9 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -67,11 +67,11 @@ namespace ts { name: "jsx", type: createMapFromTemplate({ "preserve": JsxEmit.Preserve, - "preservewithjsextension": JsxEmit.PreserveWithJsExtension, + "react-native": JsxEmit.ReactNative, "react": JsxEmit.React }), paramType: Diagnostics.KIND, - description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_preserveWithJsExtension_or_react, + description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6646017e73d..4278784e9ab 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2713,7 +2713,7 @@ "category": "Message", "code": 6079 }, - "Specify JSX code generation: 'preserve', 'preserveWithJsExtension', or 'react'": { + "Specify JSX code generation: 'preserve', 'react-native', or 'react'": { "category": "Message", "code": 6080 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9024b7c1b13..6ac7d573eda 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3299,7 +3299,7 @@ None = 0, Preserve = 1, React = 2, - PreserveWithJsExtension = 3 + ReactNative = 3 } export const enum NewLineKind { diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 34a096628f9..1895fe2d60e 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -87,7 +87,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--jsx' option must be: 'preserve', 'preservewithjsextension', 'react'", + messageText: "Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index cbfa47180f3..4e442173883 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -94,7 +94,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--jsx' option must be: 'preserve', 'preservewithjsextension', 'react'", + messageText: "Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/src/harness/unittests/matchFiles.ts b/src/harness/unittests/matchFiles.ts index 2b4bbfd4ee6..38e5c6c4393 100644 --- a/src/harness/unittests/matchFiles.ts +++ b/src/harness/unittests/matchFiles.ts @@ -909,16 +909,16 @@ namespace ts { const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); assertParsed(actual, expected); }); - it("with jsx=preserveWithJsExtension, allowJs=false", () => { + it("with jsx=react-native, allowJs=false", () => { const json = { compilerOptions: { - jsx: "preserveWithJsExtension", + jsx: "react-native", allowJs: false } }; const expected: ts.ParsedCommandLine = { options: { - jsx: ts.JsxEmit.PreserveWithJsExtension, + jsx: ts.JsxEmit.ReactNative, allowJs: false }, errors: [], @@ -986,16 +986,16 @@ namespace ts { const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); assertParsed(actual, expected); }); - it("with jsx=preserveWithJsExtension, allowJs=true", () => { + it("with jsx=react-native, allowJs=true", () => { const json = { compilerOptions: { - jsx: "preserveWithJsExtension", + jsx: "react-native", allowJs: true } }; const expected: ts.ParsedCommandLine = { options: { - jsx: ts.JsxEmit.PreserveWithJsExtension, + jsx: ts.JsxEmit.ReactNative, allowJs: true }, errors: [], diff --git a/src/server/protocol.ts b/src/server/protocol.ts index b18c887126b..e3fe17362d7 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2272,11 +2272,11 @@ namespace ts.server.protocol { export namespace JsxEmit { export type None = "None"; export type Preserve = "Preserve"; - export type PreserveWithJsExtension = "PreserveWithJsExtension"; + export type ReactNative = "ReactNative"; export type React = "React"; } - export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.PreserveWithJsExtension; + export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; export namespace ModuleKind { export type None = "None"; diff --git a/tests/baselines/reference/getEmitOutputTsxFile_PreserveWithJsExtension.baseline b/tests/baselines/reference/getEmitOutputTsxFile_ReactNative.baseline similarity index 100% rename from tests/baselines/reference/getEmitOutputTsxFile_PreserveWithJsExtension.baseline rename to tests/baselines/reference/getEmitOutputTsxFile_ReactNative.baseline diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_PreserveWithJsExtension.ts b/tests/cases/fourslash/getEmitOutputTsxFile_ReactNative.ts similarity index 75% rename from tests/cases/fourslash/getEmitOutputTsxFile_PreserveWithJsExtension.ts rename to tests/cases/fourslash/getEmitOutputTsxFile_ReactNative.ts index a1e4ce2d984..c2aac0e9d03 100644 --- a/tests/cases/fourslash/getEmitOutputTsxFile_PreserveWithJsExtension.ts +++ b/tests/cases/fourslash/getEmitOutputTsxFile_ReactNative.ts @@ -1,9 +1,9 @@ /// -// @BaselineFile: getEmitOutputTsxFile_PreserveWithJsExtension.baseline +// @BaselineFile: getEmitOutputTsxFile_ReactNative.baseline // @declaration: true // @sourceMap: true -// @jsx: preserveWithJsExtension +// @jsx: react-native // @Filename: inputFile1.ts // @emitThisFile: true diff --git a/tests/cases/unittests/matchFiles.ts b/tests/cases/unittests/matchFiles.ts index ef982f5f2bb..e3448136c08 100644 --- a/tests/cases/unittests/matchFiles.ts +++ b/tests/cases/unittests/matchFiles.ts @@ -898,16 +898,16 @@ namespace ts { assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); }); - it("with jsx=preserveWithJsExtension, allowJs=false", () => { + it("with jsx=react-native, allowJs=false", () => { const json = { compilerOptions: { - jsx: "preserveWithJsExtension", + jsx: "react-native", allowJs: false } }; const expected: ts.ParsedCommandLine = { options: { - jsx: ts.JsxEmit.PreserveWithJsExtension, + jsx: ts.JsxEmit.ReactNative, allowJs: false }, errors: [], @@ -981,16 +981,16 @@ namespace ts { assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); }); - it("with jsx=preserveWithJsExtension, allowJs=true", () => { + it("with jsx=react-native, allowJs=true", () => { const json = { compilerOptions: { - jsx: "preserveWithJsExtension", + jsx: "react-native", allowJs: true } }; const expected: ts.ParsedCommandLine = { options: { - jsx: ts.JsxEmit.PreserveWithJsExtension, + jsx: ts.JsxEmit.ReactNative, allowJs: true }, errors: [], From 7bf52ee1fde05154eb38042e63ac1ef95d0a415d Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Mon, 23 Jan 2017 22:08:39 +0100 Subject: [PATCH 165/175] add notifications and tests for jsx react-native es3 --- src/compiler/transformers/es5.ts | 4 ++-- tests/baselines/reference/es3-jsx-preserve.js | 11 +++++++++++ tests/baselines/reference/es3-jsx-preserve.symbols | 11 +++++++++++ tests/baselines/reference/es3-jsx-preserve.types | 13 +++++++++++++ tests/baselines/reference/es3-jsx-react-native.js | 11 +++++++++++ .../reference/es3-jsx-react-native.symbols | 11 +++++++++++ .../baselines/reference/es3-jsx-react-native.types | 13 +++++++++++++ tests/baselines/reference/es3-jsx-react.js | 11 +++++++++++ tests/baselines/reference/es3-jsx-react.symbols | 11 +++++++++++ tests/baselines/reference/es3-jsx-react.types | 13 +++++++++++++ tests/cases/compiler/es3-jsx-preserve.tsx | 9 +++++++++ tests/cases/compiler/es3-jsx-react-native.tsx | 9 +++++++++ tests/cases/compiler/es3-jsx-react.tsx | 9 +++++++++ 13 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/es3-jsx-preserve.js create mode 100644 tests/baselines/reference/es3-jsx-preserve.symbols create mode 100644 tests/baselines/reference/es3-jsx-preserve.types create mode 100644 tests/baselines/reference/es3-jsx-react-native.js create mode 100644 tests/baselines/reference/es3-jsx-react-native.symbols create mode 100644 tests/baselines/reference/es3-jsx-react-native.types create mode 100644 tests/baselines/reference/es3-jsx-react.js create mode 100644 tests/baselines/reference/es3-jsx-react.symbols create mode 100644 tests/baselines/reference/es3-jsx-react.types create mode 100644 tests/cases/compiler/es3-jsx-preserve.tsx create mode 100644 tests/cases/compiler/es3-jsx-react-native.tsx create mode 100644 tests/cases/compiler/es3-jsx-react.tsx diff --git a/src/compiler/transformers/es5.ts b/src/compiler/transformers/es5.ts index 6dd875965d9..972b9214f16 100644 --- a/src/compiler/transformers/es5.ts +++ b/src/compiler/transformers/es5.ts @@ -14,7 +14,7 @@ namespace ts { // enable emit notification only if using --jsx preserve let previousOnEmitNode: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; let noSubstitution: boolean[]; - if (compilerOptions.jsx === JsxEmit.Preserve) { + if (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; context.enableEmitNotification(SyntaxKind.JsxOpeningElement); @@ -116,4 +116,4 @@ namespace ts { return undefined; } } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/es3-jsx-preserve.js b/tests/baselines/reference/es3-jsx-preserve.js new file mode 100644 index 00000000000..cb1ba2a887d --- /dev/null +++ b/tests/baselines/reference/es3-jsx-preserve.js @@ -0,0 +1,11 @@ +//// [es3-jsx-preserve.tsx] + +const React: any = null; + +const elem =
; + + + +//// [es3-jsx-preserve.jsx] +var React = null; +var elem =
; diff --git a/tests/baselines/reference/es3-jsx-preserve.symbols b/tests/baselines/reference/es3-jsx-preserve.symbols new file mode 100644 index 00000000000..61c9260223f --- /dev/null +++ b/tests/baselines/reference/es3-jsx-preserve.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/es3-jsx-preserve.tsx === + +const React: any = null; +>React : Symbol(React, Decl(es3-jsx-preserve.tsx, 1, 5)) + +const elem =
; +>elem : Symbol(elem, Decl(es3-jsx-preserve.tsx, 3, 5)) +>div : Symbol(unknown) +>div : Symbol(unknown) + + diff --git a/tests/baselines/reference/es3-jsx-preserve.types b/tests/baselines/reference/es3-jsx-preserve.types new file mode 100644 index 00000000000..b37fe8af567 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-preserve.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/es3-jsx-preserve.tsx === + +const React: any = null; +>React : any +>null : null + +const elem =
; +>elem : any +>
: any +>div : any +>div : any + + diff --git a/tests/baselines/reference/es3-jsx-react-native.js b/tests/baselines/reference/es3-jsx-react-native.js new file mode 100644 index 00000000000..08e6e25502b --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react-native.js @@ -0,0 +1,11 @@ +//// [es3-jsx-react-native.tsx] + +const React: any = null; + +const elem =
; + + + +//// [es3-jsx-react-native.js] +var React = null; +var elem =
; diff --git a/tests/baselines/reference/es3-jsx-react-native.symbols b/tests/baselines/reference/es3-jsx-react-native.symbols new file mode 100644 index 00000000000..e7f010bd2ea --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react-native.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/es3-jsx-react-native.tsx === + +const React: any = null; +>React : Symbol(React, Decl(es3-jsx-react-native.tsx, 1, 5)) + +const elem =
; +>elem : Symbol(elem, Decl(es3-jsx-react-native.tsx, 3, 5)) +>div : Symbol(unknown) +>div : Symbol(unknown) + + diff --git a/tests/baselines/reference/es3-jsx-react-native.types b/tests/baselines/reference/es3-jsx-react-native.types new file mode 100644 index 00000000000..1bf199606f2 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react-native.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/es3-jsx-react-native.tsx === + +const React: any = null; +>React : any +>null : null + +const elem =
; +>elem : any +>
: any +>div : any +>div : any + + diff --git a/tests/baselines/reference/es3-jsx-react.js b/tests/baselines/reference/es3-jsx-react.js new file mode 100644 index 00000000000..861dde74c86 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react.js @@ -0,0 +1,11 @@ +//// [es3-jsx-react.tsx] + +const React: any = null; + +const elem =
; + + + +//// [es3-jsx-react.js] +var React = null; +var elem = React.createElement("div", null); diff --git a/tests/baselines/reference/es3-jsx-react.symbols b/tests/baselines/reference/es3-jsx-react.symbols new file mode 100644 index 00000000000..465cfab7ea9 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/es3-jsx-react.tsx === + +const React: any = null; +>React : Symbol(React, Decl(es3-jsx-react.tsx, 1, 5)) + +const elem =
; +>elem : Symbol(elem, Decl(es3-jsx-react.tsx, 3, 5)) +>div : Symbol(unknown) +>div : Symbol(unknown) + + diff --git a/tests/baselines/reference/es3-jsx-react.types b/tests/baselines/reference/es3-jsx-react.types new file mode 100644 index 00000000000..b7734ffc1f0 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/es3-jsx-react.tsx === + +const React: any = null; +>React : any +>null : null + +const elem =
; +>elem : any +>
: any +>div : any +>div : any + + diff --git a/tests/cases/compiler/es3-jsx-preserve.tsx b/tests/cases/compiler/es3-jsx-preserve.tsx new file mode 100644 index 00000000000..f6092e692b4 --- /dev/null +++ b/tests/cases/compiler/es3-jsx-preserve.tsx @@ -0,0 +1,9 @@ +// @target: ES3 +// @sourcemap: false +// @declaration: false +// @jsx: preserve + +const React: any = null; + +const elem =
; + diff --git a/tests/cases/compiler/es3-jsx-react-native.tsx b/tests/cases/compiler/es3-jsx-react-native.tsx new file mode 100644 index 00000000000..9ed0f9e003d --- /dev/null +++ b/tests/cases/compiler/es3-jsx-react-native.tsx @@ -0,0 +1,9 @@ +// @target: ES3 +// @sourcemap: false +// @declaration: false +// @jsx: react-native + +const React: any = null; + +const elem =
; + diff --git a/tests/cases/compiler/es3-jsx-react.tsx b/tests/cases/compiler/es3-jsx-react.tsx new file mode 100644 index 00000000000..d47aea9613f --- /dev/null +++ b/tests/cases/compiler/es3-jsx-react.tsx @@ -0,0 +1,9 @@ +// @target: ES3 +// @sourcemap: false +// @declaration: false +// @jsx: react + +const React: any = null; + +const elem =
; + From 6fda5a1b3a3018623e3b3d49ab9520a9af24510c Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Mon, 23 Jan 2017 22:14:51 +0100 Subject: [PATCH 166/175] Update comment about jsx react-native in es5.ts --- src/compiler/transformers/es5.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/transformers/es5.ts b/src/compiler/transformers/es5.ts index 972b9214f16..c3b011fe36d 100644 --- a/src/compiler/transformers/es5.ts +++ b/src/compiler/transformers/es5.ts @@ -11,7 +11,7 @@ namespace ts { export function transformES5(context: TransformationContext) { const compilerOptions = context.getCompilerOptions(); - // enable emit notification only if using --jsx preserve + // enable emit notification only if using --jsx preserve or react-native let previousOnEmitNode: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; let noSubstitution: boolean[]; if (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) { From da05ced2e5b8807af3698963515bc71da0997a0d Mon Sep 17 00:00:00 2001 From: falsandtru Date: Wed, 18 Jan 2017 12:05:25 +0900 Subject: [PATCH 167/175] Fix Symbol.valueOf method signature --- src/lib/es2015.symbol.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2015.symbol.d.ts b/src/lib/es2015.symbol.d.ts index cd7e45595f0..d7ea4fa0328 100644 --- a/src/lib/es2015.symbol.d.ts +++ b/src/lib/es2015.symbol.d.ts @@ -3,7 +3,7 @@ interface Symbol { toString(): string; /** Returns the primitive value of the specified object. */ - valueOf(): Object; + valueOf(): symbol; } interface SymbolConstructor { From 053b3cd893d00b63dda48085c744844128aaba43 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 23 Jan 2017 16:01:29 -0800 Subject: [PATCH 168/175] getFirstToken skips JSDoc Fixes #13519. This is a better fix than #13599. Also fixes broken tests associated with #13599. --- src/harness/unittests/jsDocParsing.ts | 13 +++++++++---- src/services/services.ts | 8 +++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index 3cafc9d49ae..98c32c77778 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -290,16 +290,21 @@ namespace ts { }); describe("getFirstToken", () => { it("gets jsdoc", () => { - const first = ts.createSourceFile("foo.ts", "/** comment */var a = true;", ts.ScriptTarget.ES5, /*setParentNodes*/ true); + const root = ts.createSourceFile("foo.ts", "/** comment */var a = true;", ts.ScriptTarget.ES5, /*setParentNodes*/ true); + assert.isDefined(root); + assert.equal(root.kind, ts.SyntaxKind.SourceFile); + const first = root.getFirstToken(); assert.isDefined(first); - assert.equal(first.kind, 263); + assert.equal(first.kind, ts.SyntaxKind.VarKeyword); }); }); describe("getLastToken", () => { it("gets jsdoc", () => { - const last = ts.createSourceFile("foo.ts", "var a = true;/** comment */", ts.ScriptTarget.ES5, /*setParentNodes*/ true); + const root = ts.createSourceFile("foo.ts", "var a = true;/** comment */", ts.ScriptTarget.ES5, /*setParentNodes*/ true); + assert.isDefined(root); + const last = root.getLastToken(); assert.isDefined(last); - assert.equal(last.kind, 263); + assert.equal(last.kind, ts.SyntaxKind.EndOfFileToken); }); }); }); diff --git a/src/services/services.ts b/src/services/services.ts index cb38b1d500e..208e1031cd2 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -193,8 +193,8 @@ namespace ts { return undefined; } - const child = children[0]; - return child.kind < SyntaxKind.FirstNode || SyntaxKind.FirstJSDocNode <= child.kind && child.kind <= SyntaxKind.LastJSDocNode ? + const child = ts.find(children, kid => kid.kind < SyntaxKind.FirstJSDocNode || kid.kind > SyntaxKind.LastJSDocNode); + return child.kind < SyntaxKind.FirstNode ? child : child.getFirstToken(sourceFile); } @@ -207,9 +207,7 @@ namespace ts { return undefined; } - return child.kind < SyntaxKind.FirstNode || SyntaxKind.FirstJSDocNode <= child.kind && child.kind <= SyntaxKind.LastJSDocNode ? - child : - child.getLastToken(sourceFile); + return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile); } } From 24bb21c55a1842393d523d8b4a26f5f230d24e10 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Tue, 24 Jan 2017 11:24:30 +0800 Subject: [PATCH 169/175] address code review --- src/compiler/checker.ts | 11 +++++++---- tests/baselines/reference/objectSpread.js | 5 ++--- tests/baselines/reference/objectSpread.symbols | 5 ++--- tests/baselines/reference/objectSpread.types | 7 +++---- .../reference/objectSpreadNegative.errors.txt | 4 ++-- tests/cases/conformance/types/spread/objectSpread.ts | 3 +-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 97ca01bc086..1a1cea4633f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6291,6 +6291,9 @@ namespace ts { if (right.flags & TypeFlags.Union) { return mapType(right, t => getSpreadType(left, t)); } + if (right.flags & TypeFlags.NonPrimitive) { + return emptyObjectType; + } const members = createMap(); const skippedPrivateMembers = createMap(); @@ -15719,12 +15722,12 @@ namespace ts { } } - /** + /** * Static members being set on a constructor function may conflict with built-in properties - * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable - * built-in properties. This check issues a transpile error when a class has a static + * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable + * built-in properties. This check issues a transpile error when a class has a static * member with the same name as a non-writable built-in property. - * + * * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 * @see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index 259b86628a5..2bc3b9e11bd 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -79,8 +79,7 @@ let computedAfter: { a: number, b: string, "at the end": number } = let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } // non primitive -let spreadNonPrimitve = { ...{}} - +let spreadNonPrimitive = { ...{}}; //// [objectSpread.js] @@ -151,5 +150,5 @@ var computedAfter = __assign({}, o, (_c = { b: 'yeah' }, _c['at the end'] = 14, var a = 12; var shortCutted = __assign({}, o, { a: a }); // non primitive -var spreadNonPrimitve = __assign({}, {}); +var spreadNonPrimitive = __assign({}, {}); var _a, _b, _c; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 69c9ed34341..1ec2520e166 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -317,7 +317,6 @@ let shortCutted: { a: number, b: string } = { ...o, a } >a : Symbol(a, Decl(objectSpread.ts, 78, 51)) // non primitive -let spreadNonPrimitve = { ...{}} ->spreadNonPrimitve : Symbol(spreadNonPrimitve, Decl(objectSpread.ts, 80, 3)) - +let spreadNonPrimitive = { ...{}}; +>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 80, 3)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 8a8df1a497f..950dab43465 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -408,10 +408,9 @@ let shortCutted: { a: number, b: string } = { ...o, a } >a : number // non primitive -let spreadNonPrimitve = { ...{}} ->spreadNonPrimitve : { constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: string): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: string): boolean; } ->{ ...{}} : { constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: string): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: string): boolean; } +let spreadNonPrimitive = { ...{}}; +>spreadNonPrimitive : {} +>{ ...{}} : {} >{} : object >{} : {} - diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 2b0960996ff..d9106d651a3 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -14,7 +14,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,19): error TS269 tests/cases/conformance/types/spread/objectSpreadNegative.ts(42,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/types/spread/objectSpreadNegative.ts(46,12): error TS2339: Property 'b' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(57,11): error TS2339: Property 'a' does not exist on type '{ constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: string): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: string): boolean; }'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(57,11): error TS2339: Property 'a' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(64,14): error TS2698: Spread types may only be created from object types. @@ -107,7 +107,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(64,14): error TS269 let spreadObj = { ...obj }; spreadObj.a; // error 'a' is not in {} ~ -!!! error TS2339: Property 'a' does not exist on type '{ constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: string): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: string): boolean; }'. +!!! error TS2339: Property 'a' does not exist on type '{}'. // generics function f(t: T, u: U) { diff --git a/tests/cases/conformance/types/spread/objectSpread.ts b/tests/cases/conformance/types/spread/objectSpread.ts index c4562e6f196..59b93bdd9e4 100644 --- a/tests/cases/conformance/types/spread/objectSpread.ts +++ b/tests/cases/conformance/types/spread/objectSpread.ts @@ -79,5 +79,4 @@ let computedAfter: { a: number, b: string, "at the end": number } = let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } // non primitive -let spreadNonPrimitve = { ...{}} - +let spreadNonPrimitive = { ...{}}; From ebb666a9c2e01a5ae1358252e0dde6a3e83f11f1 Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Tue, 24 Jan 2017 05:09:30 +0100 Subject: [PATCH 170/175] delete fourslash testcase for --jsx react-native --- .../getEmitOutputTsxFile_ReactNative.baseline | 26 ------------------- .../getEmitOutputTsxFile_ReactNative.ts | 22 ---------------- 2 files changed, 48 deletions(-) delete mode 100644 tests/baselines/reference/getEmitOutputTsxFile_ReactNative.baseline delete mode 100644 tests/cases/fourslash/getEmitOutputTsxFile_ReactNative.ts diff --git a/tests/baselines/reference/getEmitOutputTsxFile_ReactNative.baseline b/tests/baselines/reference/getEmitOutputTsxFile_ReactNative.baseline deleted file mode 100644 index 88fb0f0daf6..00000000000 --- a/tests/baselines/reference/getEmitOutputTsxFile_ReactNative.baseline +++ /dev/null @@ -1,26 +0,0 @@ -EmitSkipped: false -FileName : /tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js -// regular ts file -var t = 5; -var Bar = (function () { - function Bar() { - } - return Bar; -}()); -//# sourceMappingURL=inputFile1.js.mapFileName : /tests/cases/fourslash/inputFile1.d.ts -declare var t: number; -declare class Bar { - x: string; - y: number; -} - -EmitSkipped: false -FileName : /tests/cases/fourslash/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : /tests/cases/fourslash/inputFile2.js -var y = "my div"; -var x =
; -//# sourceMappingURL=inputFile2.js.mapFileName : /tests/cases/fourslash/inputFile2.d.ts -declare var y: string; -declare var x: any; - diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_ReactNative.ts b/tests/cases/fourslash/getEmitOutputTsxFile_ReactNative.ts deleted file mode 100644 index c2aac0e9d03..00000000000 --- a/tests/cases/fourslash/getEmitOutputTsxFile_ReactNative.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -// @BaselineFile: getEmitOutputTsxFile_ReactNative.baseline -// @declaration: true -// @sourceMap: true -// @jsx: react-native - -// @Filename: inputFile1.ts -// @emitThisFile: true -////// regular ts file -//// var t: number = 5; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.tsx -// @emitThisFile: true -//// var y = "my div"; -//// var x =
- -verify.baselineGetEmitOutput(); From 0a4632fe79c0390db616812ee9a5d2dd1fc1cff6 Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Tue, 24 Jan 2017 07:16:15 +0100 Subject: [PATCH 171/175] revert change to lib/protocol.d.ts --- lib/protocol.d.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index cd46ebcd366..d6c0246af34 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1798,10 +1798,9 @@ declare namespace ts.server.protocol { namespace JsxEmit { type None = "None"; type Preserve = "Preserve"; - type ReactNative = "ReactNative"; type React = "React"; } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; namespace ModuleKind { type None = "None"; type CommonJS = "CommonJS"; @@ -1881,4 +1880,4 @@ declare namespace ts { } import protocol = ts.server.protocol; export = protocol; -export as namespace protocol; +export as namespace protocol; \ No newline at end of file From 0d21c241b2954a1ba8b23f98c6a3f083de22d3bd Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 24 Jan 2017 09:06:46 -0800 Subject: [PATCH 172/175] Support find-all-references on mapped types. * Need to put a 'mappedTypeOrigin' property in SymbolLinks --- src/compiler/checker.ts | 15 ++++++++++++--- src/compiler/types.ts | 1 + tests/cases/fourslash/findAllRefsForMappedType.ts | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsForMappedType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bd8ff7568f3..878e7d47273 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4618,12 +4618,14 @@ namespace ts { const typeParameter = getTypeParameterFromMappedType(type); const constraintType = getConstraintTypeFromMappedType(type); const templateType = getTemplateTypeFromMappedType(type); - const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); + const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' const templateReadonly = !!type.declaration.readonlyToken; const templateOptional = !!type.declaration.questionToken; if (type.declaration.typeParameter.constraint.kind === SyntaxKind.TypeOperator) { // We have a { [P in keyof T]: X } - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + for (const propertySymbol of getPropertiesOfType(modifiersType)) { + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, IndexKind.String)) { addMemberForKeyType(stringType); } @@ -4638,7 +4640,7 @@ namespace ts { } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t: Type) { + function addMemberForKeyType(t: Type, propertySymbol?: Symbol) { // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. @@ -4654,6 +4656,9 @@ namespace ts { const prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | (isOptional ? SymbolFlags.Optional : 0), propName); prop.type = propType; prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } members.set(propName, prop); } else if (t.flags & TypeFlags.String) { @@ -20230,6 +20235,10 @@ namespace ts { const links = symbol as SymbolLinks; return [links.leftSpread, links.rightSpread]; } + if ((symbol as SymbolLinks).mappedTypeOrigin) { + return getRootSymbols((symbol as SymbolLinks).mappedTypeOrigin); + } + let target: Symbol; let next = symbol; while (next = getSymbolLinks(next).target) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6ac7d573eda..8b49af402cf 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2712,6 +2712,7 @@ containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property leftSpread?: Symbol; // Left source for synthetic spread property rightSpread?: Symbol; // Right source for synthetic spread property + mappedTypeOrigin?: Symbol; // For a property on a mapped type, points back to the orignal 'T' from 'keyof T'. hasNonUniformType?: boolean; // True if constituents have non-uniform types isPartial?: boolean; // True if syntheric property of union type occurs in some but not all constituents isDiscriminantProperty?: boolean; // True if discriminant synthetic property diff --git a/tests/cases/fourslash/findAllRefsForMappedType.ts b/tests/cases/fourslash/findAllRefsForMappedType.ts new file mode 100644 index 00000000000..620eae0815c --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForMappedType.ts @@ -0,0 +1,9 @@ +/// + +////interface T { [|a|]: number }; +////type U { [K in keyof T]: string }; +////type V = { [K in keyof U]: boolean }; +////const u: U = { [|a|]: "" } +////const v: V = { [|a|]: true } + +verify.rangesReferenceEachOther(); From b48a2811f67b66a14cd4584999a7d7ab2e723b56 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 24 Jan 2017 13:03:16 -0800 Subject: [PATCH 173/175] Update baselines --- tests/baselines/reference/mappedTypes1.js | 2 +- tests/baselines/reference/mappedTypes1.types | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/mappedTypes1.js b/tests/baselines/reference/mappedTypes1.js index 1998ad5ab6b..4dd8f172179 100644 --- a/tests/baselines/reference/mappedTypes1.js +++ b/tests/baselines/reference/mappedTypes1.js @@ -139,9 +139,9 @@ declare let x2: string; declare let x3: number; declare let x4: { toString: void; - valueOf: void; toFixed: void; toExponential: void; toPrecision: void; + valueOf: void; toLocaleString: void; }; diff --git a/tests/baselines/reference/mappedTypes1.types b/tests/baselines/reference/mappedTypes1.types index 35d13143bab..a9a7f53a899 100644 --- a/tests/baselines/reference/mappedTypes1.types +++ b/tests/baselines/reference/mappedTypes1.types @@ -165,7 +165,7 @@ let x3 = f3(); >f3 : () => { [P in keyof T1]: void; } let x4 = f4(); ->x4 : { toString: void; valueOf: void; toFixed: void; toExponential: void; toPrecision: void; toLocaleString: void; } ->f4() : { toString: void; valueOf: void; toFixed: void; toExponential: void; toPrecision: void; toLocaleString: void; } +>x4 : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; } +>f4() : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; } >f4 : () => { [P in keyof T1]: void; } From a478bfddd2233d3579a2b037fc0df32807cb0ebe Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 24 Jan 2017 13:44:36 -0800 Subject: [PATCH 174/175] Simplify code in 'rename' --- src/services/rename.ts | 172 ++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 88 deletions(-) diff --git a/src/services/rename.ts b/src/services/rename.ts index 6f28e505f79..afb16618b03 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -1,98 +1,94 @@ /* @internal */ namespace ts.Rename { export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo { - const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); - const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); + const renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, getIsDefinedInLibraryFile(defaultLibFileName, getCanonicalFileName)) + : undefined; + return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element); + } - if (node) { - if (node.kind === SyntaxKind.Identifier || - node.kind === SyntaxKind.StringLiteral || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isThis(node)) { - const symbol = typeChecker.getSymbolAtLocation(node); - - // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - const declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - if (forEach(declarations, isDefinedInLibraryFile)) { - return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - - const displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); - const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind, - displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === SyntaxKind.StringLiteral) { - const type = getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - const displayName = stripQuotes(type.text); - return { - canRename: true, - kind: ScriptElementKind.variableElement, - displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } + function getIsDefinedInLibraryFile(defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string): (declaration: Node) => boolean { + if (!defaultLibFileName) { + return () => false; } - return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element)); - - function getRenameInfoError(localizedErrorMessage: string): RenameInfo { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } - - function isDefinedInLibraryFile(declaration: Node) { - if (defaultLibFileName) { - const sourceFile = declaration.getSourceFile(); - const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } - } - return false; - } - - function createTriggerSpanForNode(node: Node, sourceFile: SourceFile) { - let start = node.getStart(sourceFile); - let width = node.getWidth(sourceFile); - if (node.kind === SyntaxKind.StringLiteral) { - // Exclude the quotes - start += 1; - width -= 2; - } - return createTextSpan(start, width); + const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + return declaration => { + const sourceFile = declaration.getSourceFile(); + const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === canonicalDefaultLibName; } } + + function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { + const symbol = typeChecker.getSymbolAtLocation(node); + + // Only allow a symbol to be renamed if it actually has at least one declaration. + if (symbol) { + const declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + // Disallow rename for elements that are defined in the standard TypeScript library. + if (some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + + const displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); + const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === SyntaxKind.StringLiteral) { + const type = getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + + const displayName = stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ScriptElementKind.variableElement, ScriptElementKindModifier.none, node, sourceFile); + } + } + } + + function getRenameInfoSuccess(displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, node: Node, sourceFile: SourceFile): RenameInfo { + return { + canRename: true, + kind, + displayName, + localizedErrorMessage: undefined, + fullDisplayName, + kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + + function getRenameInfoError(diagnostic: DiagnosticMessage): RenameInfo { + return { + canRename: false, + localizedErrorMessage: getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + + function createTriggerSpanForNode(node: Node, sourceFile: SourceFile) { + let start = node.getStart(sourceFile); + let width = node.getWidth(sourceFile); + if (node.kind === SyntaxKind.StringLiteral) { + // Exclude the quotes + start += 1; + width -= 2; + } + return createTextSpan(start, width); + } + + function nodeIsEligibleForRename(node: Node) { + return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isThis(node); + } } From 33b8677cb52eb54a3d4d8365fb3e6b7eba2c0dec Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 24 Jan 2017 14:32:39 -0800 Subject: [PATCH 175/175] Change "getIsDefinedInLibraryFile" back to just "isDefinedInLibraryFile" --- src/services/rename.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/services/rename.ts b/src/services/rename.ts index afb16618b03..2e9396888ef 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -1,23 +1,21 @@ /* @internal */ namespace ts.Rename { export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo { + const getCanonicalDefaultLibName = memoize(() => getCanonicalFileName(ts.normalizePath(defaultLibFileName))); const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); const renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, typeChecker, sourceFile, getIsDefinedInLibraryFile(defaultLibFileName, getCanonicalFileName)) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) : undefined; return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element); - } - function getIsDefinedInLibraryFile(defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string): (declaration: Node) => boolean { - if (!defaultLibFileName) { - return () => false; - } + function isDefinedInLibraryFile(declaration: Node) { + if (!defaultLibFileName) { + return false; + } - const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); - return declaration => { const sourceFile = declaration.getSourceFile(); const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - return canonicalName === canonicalDefaultLibName; + return canonicalName === getCanonicalDefaultLibName(); } }